@Test void testNewInstance() { EntityType entityType = createAttributeMetadataMock(); attribute = new Attribute(entityType); AttributeFactory attributeFactory = mock(AttributeFactory.class); when(attributeFactory.create()).thenReturn(mock(Attribute.class)); Attribute attribute = mock(Attribute.class); when(attribute.isVisible()).thenReturn(true); when(attribute.getNullableExpression()).thenReturn("nullableExpression"); when(attribute.getValidationExpression()).thenReturn("expression"); Attribute attributeCopy = Attribute.newInstance(attribute, SHALLOW_COPY_ATTRS, attributeFactory); verify(attributeCopy).setVisible(true); verify(attributeCopy).setNullableExpression("nullableExpression"); verify(attributeCopy).setValidationExpression("expression"); }
public static Attribute newInstance( Attribute attrMeta, AttributeCopyMode attrCopyMode, AttributeFactory attrFactory) { Attribute attrMetaCopy = attrFactory.create(); attrMetaCopy.setName(attrMeta.getName()); attrMetaCopy.setEntity(attrMeta.getEntity()); attrMetaCopy.setSequenceNumber(attrMeta.getSequenceNumber()); attrMetaCopy.setDataType(attrMeta.getDataType()); attrMetaCopy.setIdAttribute(attrMeta.isIdAttribute()); attrMetaCopy.setLabelAttribute(attrMeta.isLabelAttribute()); attrMetaCopy.setLookupAttributeIndex(attrMeta.getLookupAttributeIndex()); if (attrMeta.hasRefEntity()) { attrMetaCopy.setRefEntity(attrMeta.getRefEntity()); } attrMetaCopy.setMappedBy(attrMeta.getMappedBy()); attrMetaCopy.setOrderBy(attrMeta.getOrderBy()); attrMetaCopy.setExpression(attrMeta.getExpression()); attrMetaCopy.setNillable(attrMeta.isNillable()); attrMetaCopy.setAuto(attrMeta.isAuto()); attrMetaCopy.setVisible(attrMeta.isVisible()); attrMetaCopy.setLabel(attrMeta.getLabel()); attrMetaCopy.setDescription(attrMeta.getDescription()); attrMetaCopy.setAggregatable(attrMeta.isAggregatable()); attrMetaCopy.setEnumOptions(attrMeta.getEnumOptions()); attrMetaCopy.setRangeMin(attrMeta.getRangeMin()); attrMetaCopy.setRangeMax(attrMeta.getRangeMax()); attrMetaCopy.setReadOnly(attrMeta.isReadOnly()); attrMetaCopy.setUnique(attrMeta.isUnique()); Attribute parentAttr = attrMeta.getParent(); if (attrCopyMode == DEEP_COPY_ATTRS) { attrMetaCopy.setParent( parentAttr != null ? Attribute.newInstance(parentAttr, attrCopyMode, attrFactory) : null); } else { attrMetaCopy.setParent(parentAttr); } attrMetaCopy.setTags(Lists.newArrayList(attrMeta.getTags())); attrMetaCopy.setNullableExpression(attrMeta.getNullableExpression()); attrMetaCopy.setValidationExpression(attrMeta.getValidationExpression()); attrMetaCopy.setVisibleExpression(attrMeta.getVisibleExpression()); attrMetaCopy.setDefaultValue(attrMeta.getDefaultValue()); return attrMetaCopy; }
Attribute extends StaticEntity implements Labeled { public static Attribute newInstance( Attribute attrMeta, AttributeCopyMode attrCopyMode, AttributeFactory attrFactory) { Attribute attrMetaCopy = attrFactory.create(); attrMetaCopy.setName(attrMeta.getName()); attrMetaCopy.setEntity(attrMeta.getEntity()); attrMetaCopy.setSequenceNumber(attrMeta.getSequenceNumber()); attrMetaCopy.setDataType(attrMeta.getDataType()); attrMetaCopy.setIdAttribute(attrMeta.isIdAttribute()); attrMetaCopy.setLabelAttribute(attrMeta.isLabelAttribute()); attrMetaCopy.setLookupAttributeIndex(attrMeta.getLookupAttributeIndex()); if (attrMeta.hasRefEntity()) { attrMetaCopy.setRefEntity(attrMeta.getRefEntity()); } attrMetaCopy.setMappedBy(attrMeta.getMappedBy()); attrMetaCopy.setOrderBy(attrMeta.getOrderBy()); attrMetaCopy.setExpression(attrMeta.getExpression()); attrMetaCopy.setNillable(attrMeta.isNillable()); attrMetaCopy.setAuto(attrMeta.isAuto()); attrMetaCopy.setVisible(attrMeta.isVisible()); attrMetaCopy.setLabel(attrMeta.getLabel()); attrMetaCopy.setDescription(attrMeta.getDescription()); attrMetaCopy.setAggregatable(attrMeta.isAggregatable()); attrMetaCopy.setEnumOptions(attrMeta.getEnumOptions()); attrMetaCopy.setRangeMin(attrMeta.getRangeMin()); attrMetaCopy.setRangeMax(attrMeta.getRangeMax()); attrMetaCopy.setReadOnly(attrMeta.isReadOnly()); attrMetaCopy.setUnique(attrMeta.isUnique()); Attribute parentAttr = attrMeta.getParent(); if (attrCopyMode == DEEP_COPY_ATTRS) { attrMetaCopy.setParent( parentAttr != null ? Attribute.newInstance(parentAttr, attrCopyMode, attrFactory) : null); } else { attrMetaCopy.setParent(parentAttr); } attrMetaCopy.setTags(Lists.newArrayList(attrMeta.getTags())); attrMetaCopy.setNullableExpression(attrMeta.getNullableExpression()); attrMetaCopy.setValidationExpression(attrMeta.getValidationExpression()); attrMetaCopy.setVisibleExpression(attrMeta.getVisibleExpression()); attrMetaCopy.setDefaultValue(attrMeta.getDefaultValue()); return attrMetaCopy; } }
Attribute extends StaticEntity implements Labeled { public static Attribute newInstance( Attribute attrMeta, AttributeCopyMode attrCopyMode, AttributeFactory attrFactory) { Attribute attrMetaCopy = attrFactory.create(); attrMetaCopy.setName(attrMeta.getName()); attrMetaCopy.setEntity(attrMeta.getEntity()); attrMetaCopy.setSequenceNumber(attrMeta.getSequenceNumber()); attrMetaCopy.setDataType(attrMeta.getDataType()); attrMetaCopy.setIdAttribute(attrMeta.isIdAttribute()); attrMetaCopy.setLabelAttribute(attrMeta.isLabelAttribute()); attrMetaCopy.setLookupAttributeIndex(attrMeta.getLookupAttributeIndex()); if (attrMeta.hasRefEntity()) { attrMetaCopy.setRefEntity(attrMeta.getRefEntity()); } attrMetaCopy.setMappedBy(attrMeta.getMappedBy()); attrMetaCopy.setOrderBy(attrMeta.getOrderBy()); attrMetaCopy.setExpression(attrMeta.getExpression()); attrMetaCopy.setNillable(attrMeta.isNillable()); attrMetaCopy.setAuto(attrMeta.isAuto()); attrMetaCopy.setVisible(attrMeta.isVisible()); attrMetaCopy.setLabel(attrMeta.getLabel()); attrMetaCopy.setDescription(attrMeta.getDescription()); attrMetaCopy.setAggregatable(attrMeta.isAggregatable()); attrMetaCopy.setEnumOptions(attrMeta.getEnumOptions()); attrMetaCopy.setRangeMin(attrMeta.getRangeMin()); attrMetaCopy.setRangeMax(attrMeta.getRangeMax()); attrMetaCopy.setReadOnly(attrMeta.isReadOnly()); attrMetaCopy.setUnique(attrMeta.isUnique()); Attribute parentAttr = attrMeta.getParent(); if (attrCopyMode == DEEP_COPY_ATTRS) { attrMetaCopy.setParent( parentAttr != null ? Attribute.newInstance(parentAttr, attrCopyMode, attrFactory) : null); } else { attrMetaCopy.setParent(parentAttr); } attrMetaCopy.setTags(Lists.newArrayList(attrMeta.getTags())); attrMetaCopy.setNullableExpression(attrMeta.getNullableExpression()); attrMetaCopy.setValidationExpression(attrMeta.getValidationExpression()); attrMetaCopy.setVisibleExpression(attrMeta.getVisibleExpression()); attrMetaCopy.setDefaultValue(attrMeta.getDefaultValue()); return attrMetaCopy; } Attribute(Entity entity);  Attribute(EntityType entityType);  Attribute(String attrId, EntityType entityType); }
Attribute extends StaticEntity implements Labeled { public static Attribute newInstance( Attribute attrMeta, AttributeCopyMode attrCopyMode, AttributeFactory attrFactory) { Attribute attrMetaCopy = attrFactory.create(); attrMetaCopy.setName(attrMeta.getName()); attrMetaCopy.setEntity(attrMeta.getEntity()); attrMetaCopy.setSequenceNumber(attrMeta.getSequenceNumber()); attrMetaCopy.setDataType(attrMeta.getDataType()); attrMetaCopy.setIdAttribute(attrMeta.isIdAttribute()); attrMetaCopy.setLabelAttribute(attrMeta.isLabelAttribute()); attrMetaCopy.setLookupAttributeIndex(attrMeta.getLookupAttributeIndex()); if (attrMeta.hasRefEntity()) { attrMetaCopy.setRefEntity(attrMeta.getRefEntity()); } attrMetaCopy.setMappedBy(attrMeta.getMappedBy()); attrMetaCopy.setOrderBy(attrMeta.getOrderBy()); attrMetaCopy.setExpression(attrMeta.getExpression()); attrMetaCopy.setNillable(attrMeta.isNillable()); attrMetaCopy.setAuto(attrMeta.isAuto()); attrMetaCopy.setVisible(attrMeta.isVisible()); attrMetaCopy.setLabel(attrMeta.getLabel()); attrMetaCopy.setDescription(attrMeta.getDescription()); attrMetaCopy.setAggregatable(attrMeta.isAggregatable()); attrMetaCopy.setEnumOptions(attrMeta.getEnumOptions()); attrMetaCopy.setRangeMin(attrMeta.getRangeMin()); attrMetaCopy.setRangeMax(attrMeta.getRangeMax()); attrMetaCopy.setReadOnly(attrMeta.isReadOnly()); attrMetaCopy.setUnique(attrMeta.isUnique()); Attribute parentAttr = attrMeta.getParent(); if (attrCopyMode == DEEP_COPY_ATTRS) { attrMetaCopy.setParent( parentAttr != null ? Attribute.newInstance(parentAttr, attrCopyMode, attrFactory) : null); } else { attrMetaCopy.setParent(parentAttr); } attrMetaCopy.setTags(Lists.newArrayList(attrMeta.getTags())); attrMetaCopy.setNullableExpression(attrMeta.getNullableExpression()); attrMetaCopy.setValidationExpression(attrMeta.getValidationExpression()); attrMetaCopy.setVisibleExpression(attrMeta.getVisibleExpression()); attrMetaCopy.setDefaultValue(attrMeta.getDefaultValue()); return attrMetaCopy; } Attribute(Entity entity);  Attribute(EntityType entityType);  Attribute(String attrId, EntityType entityType); static Attribute newInstance(
      Attribute attrMeta, AttributeCopyMode attrCopyMode, AttributeFactory attrFactory); String getIdentifier(); Attribute setIdentifier(String identifier); String getName(); Attribute setName(String name); Integer getSequenceNumber(); Attribute setSequenceNumber(int seqNr); EntityType getEntity(); Attribute setEntity(EntityType entityMeta); boolean isIdAttribute(); Attribute setIdAttribute(Boolean isIdAttr); boolean isLabelAttribute(); Attribute setLabelAttribute(Boolean isLabelAttr); @Nullable @CheckForNull Integer getLookupAttributeIndex(); Attribute setLookupAttributeIndex(Integer lookupAttrIdx); @Nullable @CheckForNull String getLabel(); @Nullable @CheckForNull String getLabel(String languageCode); Attribute setLabel(String label); Attribute setLabel(String languageCode, String label); @Nullable @CheckForNull String getDescription(); @Nullable @CheckForNull String getDescription(String languageCode); Attribute setDescription(String description); Attribute setDescription(String languageCode, String description); AttributeType getDataType(); Attribute setDataType(AttributeType dataType); @Nullable @CheckForNull Boolean getCascadeDelete(); Attribute setCascadeDelete(Boolean isCascadeDelete); Iterable<Attribute> getChildren(); boolean hasRefEntity(); EntityType getRefEntity(); Attribute setRefEntity(EntityType refEntity); @Nullable @CheckForNull Attribute getMappedBy(); Attribute setMappedBy(Attribute mappedByAttr); boolean isMappedBy(); @Nullable @CheckForNull Sort getOrderBy(); Attribute setOrderBy(Sort sort); @Nullable @CheckForNull String getExpression(); Attribute setExpression(String expression); boolean hasExpression(); boolean isNillable(); Attribute setNillable(boolean nillable); boolean isAuto(); Attribute setAuto(boolean auto); boolean isVisible(); Attribute setVisible(boolean visible); boolean isAggregatable(); Attribute setAggregatable(boolean isAggregatable); List<String> getEnumOptions(); Attribute setEnumOptions(Class<? extends Enum<?>> e); Attribute setEnumOptions(List<String> enumOptions); @Nullable @CheckForNull Long getRangeMin(); Attribute setRangeMin(Long rangeMin); @Nullable @CheckForNull Long getRangeMax(); Attribute setRangeMax(Long rangeMax); boolean isReadOnly(); Attribute setReadOnly(boolean readOnly); boolean isUnique(); Attribute setUnique(boolean unique); @Nullable @CheckForNull String getNullableExpression(); Attribute setNullableExpression(String nullableExpression); @Nullable @CheckForNull String getVisibleExpression(); Attribute setVisibleExpression(String visibleExpression); @Nullable @CheckForNull String getValidationExpression(); Attribute setValidationExpression(String validationExpression); boolean hasDefaultValue(); @Nullable @CheckForNull String getDefaultValue(); Attribute setDefaultValue(String defaultValue); Range getRange(); Attribute setRange(Range range); @Nullable @CheckForNull Attribute getParent(); Attribute setParent(Attribute parentAttr); Attribute getChild(String attrName); Iterable<Tag> getTags(); Attribute setTags(Iterable<Tag> tags); void addTag(Tag tag); void removeTag(Tag tag); void setDefaultValues(); @Override String toString(); Attribute getInversedBy(); boolean isInversedBy(); }
Attribute extends StaticEntity implements Labeled { public static Attribute newInstance( Attribute attrMeta, AttributeCopyMode attrCopyMode, AttributeFactory attrFactory) { Attribute attrMetaCopy = attrFactory.create(); attrMetaCopy.setName(attrMeta.getName()); attrMetaCopy.setEntity(attrMeta.getEntity()); attrMetaCopy.setSequenceNumber(attrMeta.getSequenceNumber()); attrMetaCopy.setDataType(attrMeta.getDataType()); attrMetaCopy.setIdAttribute(attrMeta.isIdAttribute()); attrMetaCopy.setLabelAttribute(attrMeta.isLabelAttribute()); attrMetaCopy.setLookupAttributeIndex(attrMeta.getLookupAttributeIndex()); if (attrMeta.hasRefEntity()) { attrMetaCopy.setRefEntity(attrMeta.getRefEntity()); } attrMetaCopy.setMappedBy(attrMeta.getMappedBy()); attrMetaCopy.setOrderBy(attrMeta.getOrderBy()); attrMetaCopy.setExpression(attrMeta.getExpression()); attrMetaCopy.setNillable(attrMeta.isNillable()); attrMetaCopy.setAuto(attrMeta.isAuto()); attrMetaCopy.setVisible(attrMeta.isVisible()); attrMetaCopy.setLabel(attrMeta.getLabel()); attrMetaCopy.setDescription(attrMeta.getDescription()); attrMetaCopy.setAggregatable(attrMeta.isAggregatable()); attrMetaCopy.setEnumOptions(attrMeta.getEnumOptions()); attrMetaCopy.setRangeMin(attrMeta.getRangeMin()); attrMetaCopy.setRangeMax(attrMeta.getRangeMax()); attrMetaCopy.setReadOnly(attrMeta.isReadOnly()); attrMetaCopy.setUnique(attrMeta.isUnique()); Attribute parentAttr = attrMeta.getParent(); if (attrCopyMode == DEEP_COPY_ATTRS) { attrMetaCopy.setParent( parentAttr != null ? Attribute.newInstance(parentAttr, attrCopyMode, attrFactory) : null); } else { attrMetaCopy.setParent(parentAttr); } attrMetaCopy.setTags(Lists.newArrayList(attrMeta.getTags())); attrMetaCopy.setNullableExpression(attrMeta.getNullableExpression()); attrMetaCopy.setValidationExpression(attrMeta.getValidationExpression()); attrMetaCopy.setVisibleExpression(attrMeta.getVisibleExpression()); attrMetaCopy.setDefaultValue(attrMeta.getDefaultValue()); return attrMetaCopy; } Attribute(Entity entity);  Attribute(EntityType entityType);  Attribute(String attrId, EntityType entityType); static Attribute newInstance(
      Attribute attrMeta, AttributeCopyMode attrCopyMode, AttributeFactory attrFactory); String getIdentifier(); Attribute setIdentifier(String identifier); String getName(); Attribute setName(String name); Integer getSequenceNumber(); Attribute setSequenceNumber(int seqNr); EntityType getEntity(); Attribute setEntity(EntityType entityMeta); boolean isIdAttribute(); Attribute setIdAttribute(Boolean isIdAttr); boolean isLabelAttribute(); Attribute setLabelAttribute(Boolean isLabelAttr); @Nullable @CheckForNull Integer getLookupAttributeIndex(); Attribute setLookupAttributeIndex(Integer lookupAttrIdx); @Nullable @CheckForNull String getLabel(); @Nullable @CheckForNull String getLabel(String languageCode); Attribute setLabel(String label); Attribute setLabel(String languageCode, String label); @Nullable @CheckForNull String getDescription(); @Nullable @CheckForNull String getDescription(String languageCode); Attribute setDescription(String description); Attribute setDescription(String languageCode, String description); AttributeType getDataType(); Attribute setDataType(AttributeType dataType); @Nullable @CheckForNull Boolean getCascadeDelete(); Attribute setCascadeDelete(Boolean isCascadeDelete); Iterable<Attribute> getChildren(); boolean hasRefEntity(); EntityType getRefEntity(); Attribute setRefEntity(EntityType refEntity); @Nullable @CheckForNull Attribute getMappedBy(); Attribute setMappedBy(Attribute mappedByAttr); boolean isMappedBy(); @Nullable @CheckForNull Sort getOrderBy(); Attribute setOrderBy(Sort sort); @Nullable @CheckForNull String getExpression(); Attribute setExpression(String expression); boolean hasExpression(); boolean isNillable(); Attribute setNillable(boolean nillable); boolean isAuto(); Attribute setAuto(boolean auto); boolean isVisible(); Attribute setVisible(boolean visible); boolean isAggregatable(); Attribute setAggregatable(boolean isAggregatable); List<String> getEnumOptions(); Attribute setEnumOptions(Class<? extends Enum<?>> e); Attribute setEnumOptions(List<String> enumOptions); @Nullable @CheckForNull Long getRangeMin(); Attribute setRangeMin(Long rangeMin); @Nullable @CheckForNull Long getRangeMax(); Attribute setRangeMax(Long rangeMax); boolean isReadOnly(); Attribute setReadOnly(boolean readOnly); boolean isUnique(); Attribute setUnique(boolean unique); @Nullable @CheckForNull String getNullableExpression(); Attribute setNullableExpression(String nullableExpression); @Nullable @CheckForNull String getVisibleExpression(); Attribute setVisibleExpression(String visibleExpression); @Nullable @CheckForNull String getValidationExpression(); Attribute setValidationExpression(String validationExpression); boolean hasDefaultValue(); @Nullable @CheckForNull String getDefaultValue(); Attribute setDefaultValue(String defaultValue); Range getRange(); Attribute setRange(Range range); @Nullable @CheckForNull Attribute getParent(); Attribute setParent(Attribute parentAttr); Attribute getChild(String attrName); Iterable<Tag> getTags(); Attribute setTags(Iterable<Tag> tags); void addTag(Tag tag); void removeTag(Tag tag); void setDefaultValues(); @Override String toString(); Attribute getInversedBy(); boolean isInversedBy();  }