@Test void addSequenceNumberNull() { Attribute attr1 = mock(Attribute.class); Attribute attr2 = mock(Attribute.class); Attribute attr3 = mock(Attribute.class); Attribute attribute = mock(Attribute.class); when(attr1.getSequenceNumber()).thenReturn(0); when(attr2.getSequenceNumber()).thenReturn(1); when(attr3.getSequenceNumber()).thenReturn(2); when(attribute.getSequenceNumber()).thenReturn(null); EntityType.addSequenceNumber(attribute, Lists.newArrayList(attr1, attr2, attr3)); verify(attribute).setSequenceNumber(3); }
static void addSequenceNumber(Attribute attr, Iterable<Attribute> attrs) { Integer sequenceNumber = attr.getSequenceNumber(); if (null == sequenceNumber) { int i = stream(attrs) .filter(a -> null != a.getSequenceNumber()) .mapToInt(Attribute::getSequenceNumber) .max() .orElse(-1); if (i == -1) attr.setSequenceNumber(0); else attr.setSequenceNumber(++i); } }
EntityType extends StaticEntity implements Labeled { static void addSequenceNumber(Attribute attr, Iterable<Attribute> attrs) { Integer sequenceNumber = attr.getSequenceNumber(); if (null == sequenceNumber) { int i = stream(attrs) .filter(a -> null != a.getSequenceNumber()) .mapToInt(Attribute::getSequenceNumber) .max() .orElse(-1); if (i == -1) attr.setSequenceNumber(0); else attr.setSequenceNumber(++i); } } }
EntityType extends StaticEntity implements Labeled { static void addSequenceNumber(Attribute attr, Iterable<Attribute> attrs) { Integer sequenceNumber = attr.getSequenceNumber(); if (null == sequenceNumber) { int i = stream(attrs) .filter(a -> null != a.getSequenceNumber()) .mapToInt(Attribute::getSequenceNumber) .max() .orElse(-1); if (i == -1) attr.setSequenceNumber(0); else attr.setSequenceNumber(++i); } } EntityType(Entity entity); protected  EntityType();  EntityType(EntityType entityType);  EntityType(String entityId, EntityType entityType); }
EntityType extends StaticEntity implements Labeled { static void addSequenceNumber(Attribute attr, Iterable<Attribute> attrs) { Integer sequenceNumber = attr.getSequenceNumber(); if (null == sequenceNumber) { int i = stream(attrs) .filter(a -> null != a.getSequenceNumber()) .mapToInt(Attribute::getSequenceNumber) .max() .orElse(-1); if (i == -1) attr.setSequenceNumber(0); else attr.setSequenceNumber(++i); } } EntityType(Entity entity); protected  EntityType();  EntityType(EntityType entityType);  EntityType(String entityId, EntityType entityType); static EntityType newInstance(EntityType entityType); static EntityType newInstance(
      EntityType entityType, AttributeCopyMode attrCopyMode, AttributeFactory attrFactory); static Map<String, Attribute> deepCopyAttributes(
      EntityType entityType, EntityType entityTypeCopy, AttributeFactory attrFactory); @Override Iterable<String> getAttributeNames(); String getId(); EntityType setId(String id); String getLabel(); String getLabel(String languageCode); EntityType setLabel(String label); EntityType setLabel(String languageCode, String label); @Nullable @CheckForNull String getDescription(); @Nullable @CheckForNull String getDescription(String languageCode); EntityType setDescription(String description); EntityType setDescription(String languageCode, String description); String getBackend(); EntityType setBackend(String backend); @Nullable @CheckForNull Package getPackage(); EntityType setPackage(Package pack); Attribute getIdAttribute(); Attribute getOwnIdAttribute(); Attribute getLabelAttribute(); Attribute getLabelAttribute(String langCode); Attribute getOwnLabelAttribute(); Attribute getOwnLabelAttribute(String languageCode); Attribute getLookupAttribute(String lookupAttrName); Iterable<Attribute> getLookupAttributes(); Iterable<Attribute> getOwnLookupAttributes(); boolean isAbstract(); EntityType setAbstract(boolean isAbstract); @Nullable @CheckForNull EntityType getExtends(); EntityType setExtends(EntityType extend); Iterable<Attribute> getOwnAttributes(); EntityType setOwnAllAttributes(Iterable<Attribute> attrs); Iterable<Attribute> getAttributes(); Iterable<Attribute> getAtomicAttributes(); Iterable<Attribute> getAllAttributes(); Iterable<Attribute> getOwnAllAttributes(); Attribute getAttribute(String attrName); Attribute getAttributeByName(String attributeName); Attribute getOwnAttributeById(String attributeIdentifier); EntityType addAttribute(Attribute attr, AttributeRole... attrTypes); void addAttributes(Iterable<Attribute> attrs); boolean hasAttributeWithExpression(); void removeAttribute(Attribute attr); Iterable<Tag> getTags(); EntityType setTags(Iterable<Tag> tags); @SuppressWarnings("unused") void addTag(Tag tag); void removeTag(Tag tag); void setIndexingDepth(int indexingDepth); int getIndexingDepth(); Iterable<Attribute> getOwnAtomicAttributes(); boolean hasBidirectionalAttributes(); boolean hasMappedByAttributes(); Stream<Attribute> getOwnMappedByAttributes(); Stream<Attribute> getMappedByAttributes(); boolean hasInversedByAttributes(); Stream<Attribute> getInversedByAttributes(); @Override void set(String attributeName, Object value); @Override String toString(); }
EntityType extends StaticEntity implements Labeled { static void addSequenceNumber(Attribute attr, Iterable<Attribute> attrs) { Integer sequenceNumber = attr.getSequenceNumber(); if (null == sequenceNumber) { int i = stream(attrs) .filter(a -> null != a.getSequenceNumber()) .mapToInt(Attribute::getSequenceNumber) .max() .orElse(-1); if (i == -1) attr.setSequenceNumber(0); else attr.setSequenceNumber(++i); } } EntityType(Entity entity); protected  EntityType();  EntityType(EntityType entityType);  EntityType(String entityId, EntityType entityType); static EntityType newInstance(EntityType entityType); static EntityType newInstance(
      EntityType entityType, AttributeCopyMode attrCopyMode, AttributeFactory attrFactory); static Map<String, Attribute> deepCopyAttributes(
      EntityType entityType, EntityType entityTypeCopy, AttributeFactory attrFactory); @Override Iterable<String> getAttributeNames(); String getId(); EntityType setId(String id); String getLabel(); String getLabel(String languageCode); EntityType setLabel(String label); EntityType setLabel(String languageCode, String label); @Nullable @CheckForNull String getDescription(); @Nullable @CheckForNull String getDescription(String languageCode); EntityType setDescription(String description); EntityType setDescription(String languageCode, String description); String getBackend(); EntityType setBackend(String backend); @Nullable @CheckForNull Package getPackage(); EntityType setPackage(Package pack); Attribute getIdAttribute(); Attribute getOwnIdAttribute(); Attribute getLabelAttribute(); Attribute getLabelAttribute(String langCode); Attribute getOwnLabelAttribute(); Attribute getOwnLabelAttribute(String languageCode); Attribute getLookupAttribute(String lookupAttrName); Iterable<Attribute> getLookupAttributes(); Iterable<Attribute> getOwnLookupAttributes(); boolean isAbstract(); EntityType setAbstract(boolean isAbstract); @Nullable @CheckForNull EntityType getExtends(); EntityType setExtends(EntityType extend); Iterable<Attribute> getOwnAttributes(); EntityType setOwnAllAttributes(Iterable<Attribute> attrs); Iterable<Attribute> getAttributes(); Iterable<Attribute> getAtomicAttributes(); Iterable<Attribute> getAllAttributes(); Iterable<Attribute> getOwnAllAttributes(); Attribute getAttribute(String attrName); Attribute getAttributeByName(String attributeName); Attribute getOwnAttributeById(String attributeIdentifier); EntityType addAttribute(Attribute attr, AttributeRole... attrTypes); void addAttributes(Iterable<Attribute> attrs); boolean hasAttributeWithExpression(); void removeAttribute(Attribute attr); Iterable<Tag> getTags(); EntityType setTags(Iterable<Tag> tags); @SuppressWarnings("unused") void addTag(Tag tag); void removeTag(Tag tag); void setIndexingDepth(int indexingDepth); int getIndexingDepth(); Iterable<Attribute> getOwnAtomicAttributes(); boolean hasBidirectionalAttributes(); boolean hasMappedByAttributes(); Stream<Attribute> getOwnMappedByAttributes(); Stream<Attribute> getMappedByAttributes(); boolean hasInversedByAttributes(); Stream<Attribute> getInversedByAttributes(); @Override void set(String attributeName, Object value); @Override String toString();  }