001 package org.nakedobjects.applib.adapters;
002
003 public abstract class AbstractValueSemanticsProvider<T> implements ValueSemanticsProvider<T> {
004
005 private boolean immutable;
006 private boolean equalByContent;
007
008 /**
009 * Defaults {@link #isImmutable()} to <tt>true</tt> and {@link #isEqualByContent()} to <tt>true</tt>
010 * also.
011 */
012 public AbstractValueSemanticsProvider() {
013 this(true, true);
014 }
015
016 public AbstractValueSemanticsProvider(final boolean immutable, final boolean equalByContent) {
017 this.immutable = immutable;
018 this.equalByContent = equalByContent;
019 }
020
021 public EncoderDecoder<T> getEncoderDecoder() {
022 return (EncoderDecoder<T>) (this instanceof EncoderDecoder ? this : null);
023 }
024
025 public Parser<T> getParser() {
026 return (Parser<T>) (this instanceof Parser ? this : null);
027 }
028
029 public DefaultsProvider<T> getDefaultsProvider() {
030 return (DefaultsProvider<T>) (this instanceof DefaultsProvider ? this : null);
031 }
032
033 /**
034 * Defaults to <tt>true</tt> if no-arg constructor is used.
035 */
036 public boolean isEqualByContent() {
037 return equalByContent;
038 }
039
040 /**
041 * Defaults to <tt>true</tt> if no-arg constructor is used.
042 */
043 public boolean isImmutable() {
044 return immutable;
045 }
046
047 }
048
049 // Copyright (c) Naked Objects Group Ltd.