http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/test/java/org/apache/atlas/repository/memory/InstanceE2ETest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/memory/InstanceE2ETest.java b/repository/src/test/java/org/apache/atlas/repository/memory/InstanceE2ETest.java index f9ba157..3c29bf8 100755 --- a/repository/src/test/java/org/apache/atlas/repository/memory/InstanceE2ETest.java +++ b/repository/src/test/java/org/apache/atlas/repository/memory/InstanceE2ETest.java @@ -44,43 +44,36 @@ import java.util.List; public class InstanceE2ETest extends BaseTest { - protected List<HierarchicalTypeDefinition> createHiveTypes(TypeSystem typeSystem) - throws AtlasException { + protected List<HierarchicalTypeDefinition> createHiveTypes(TypeSystem typeSystem) throws AtlasException { ArrayList<HierarchicalTypeDefinition> typeDefinitions = new ArrayList<>(); - HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = - TypesUtil.createClassTypeDef("hive_database", - ImmutableList.<String>of(), + HierarchicalTypeDefinition<ClassType> databaseTypeDefinition = TypesUtil + .createClassTypeDef("hive_database", ImmutableList.<String>of(), TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE)); typeDefinitions.add(databaseTypeDefinition); - HierarchicalTypeDefinition<ClassType> tableTypeDefinition = TypesUtil.createClassTypeDef( - "hive_table", - ImmutableList.<String>of(), - TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), - TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE), - TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE), - new AttributeDefinition("hive_database", - "hive_database", Multiplicity.REQUIRED, false, "hive_database")); + HierarchicalTypeDefinition<ClassType> tableTypeDefinition = TypesUtil + .createClassTypeDef("hive_table", ImmutableList.<String>of(), + TypesUtil.createRequiredAttrDef("name", DataTypes.STRING_TYPE), + TypesUtil.createRequiredAttrDef("description", DataTypes.STRING_TYPE), + TypesUtil.createRequiredAttrDef("type", DataTypes.STRING_TYPE), + new AttributeDefinition("hive_database", "hive_database", Multiplicity.REQUIRED, false, + "hive_database")); typeDefinitions.add(tableTypeDefinition); - HierarchicalTypeDefinition<TraitType> fetlTypeDefinition = TypesUtil.createTraitTypeDef( - "hive_fetl", - ImmutableList.<String>of(), - TypesUtil.createRequiredAttrDef("level", DataTypes.INT_TYPE)); + HierarchicalTypeDefinition<TraitType> fetlTypeDefinition = TypesUtil + .createTraitTypeDef("hive_fetl", ImmutableList.<String>of(), + TypesUtil.createRequiredAttrDef("level", DataTypes.INT_TYPE)); typeDefinitions.add(fetlTypeDefinition); - typeSystem.defineTypes( - ImmutableList.<StructTypeDefinition>of(), - ImmutableList.of(fetlTypeDefinition), + typeSystem.defineTypes(ImmutableList.<StructTypeDefinition>of(), ImmutableList.of(fetlTypeDefinition), ImmutableList.of(databaseTypeDefinition, tableTypeDefinition)); return typeDefinitions; } - protected Referenceable createHiveTableReferenceable() - throws AtlasException { + protected Referenceable createHiveTableReferenceable() throws AtlasException { Referenceable databaseInstance = new Referenceable("hive_database"); databaseInstance.set("name", "hive_database"); databaseInstance.set("description", "foo database"); @@ -99,8 +92,7 @@ public class InstanceE2ETest extends BaseTest { return tableInstance; } - protected ITypedReferenceableInstance createHiveTableInstance(TypeSystem typeSystem) - throws AtlasException { + protected ITypedReferenceableInstance createHiveTableInstance(TypeSystem typeSystem) throws AtlasException { ClassType tableType = typeSystem.getDataType(ClassType.class, "hive_table"); return tableType.convert(createHiveTableReferenceable(), Multiplicity.REQUIRED); } @@ -112,8 +104,7 @@ public class InstanceE2ETest extends BaseTest { createHiveTypes(ts); - String jsonStr = TypesSerialization$.MODULE$ - .toJson(ts, ImmutableList.of("hive_database", "hive_table")); + String jsonStr = TypesSerialization$.MODULE$.toJson(ts, ImmutableList.of("hive_database", "hive_table")); System.out.println(jsonStr); TypesDef typesDef1 = TypesSerialization$.MODULE$.fromJson(jsonStr); @@ -121,8 +112,7 @@ public class InstanceE2ETest extends BaseTest { ts.reset(); ts.defineTypes(typesDef1); - jsonStr = TypesSerialization$.MODULE$ - .toJson(ts, ImmutableList.of("hive_database", "hive_table")); + jsonStr = TypesSerialization$.MODULE$.toJson(ts, ImmutableList.of("hive_database", "hive_table")); System.out.println(jsonStr); } @@ -152,7 +142,7 @@ public class InstanceE2ETest extends BaseTest { Referenceable r = createHiveTableReferenceable(); String jsonStr = InstanceSerialization$.MODULE$.toJson(r, true); - Referenceable r1 = InstanceSerialization$.MODULE$.fromJsonReferenceable(jsonStr, true); + Referenceable r1 = InstanceSerialization$.MODULE$.fromJsonReferenceable(jsonStr, true); ClassType tableType = ts.getDataType(ClassType.class, "hive_table"); ITypedReferenceableInstance i = tableType.convert(r1, Multiplicity.REQUIRED);
http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/test/java/org/apache/atlas/repository/memory/StructTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/memory/StructTest.java b/repository/src/test/java/org/apache/atlas/repository/memory/StructTest.java index 982d881..369ffde 100755 --- a/repository/src/test/java/org/apache/atlas/repository/memory/StructTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/memory/StructTest.java @@ -38,8 +38,7 @@ public class StructTest extends BaseTest { public void setup() throws Exception { super.setup(); structType = (StructType) getTypeSystem().getDataType(StructType.class, STRUCT_TYPE_1); - recursiveStructType = (StructType) getTypeSystem() - .getDataType(StructType.class, STRUCT_TYPE_2); + recursiveStructType = (StructType) getTypeSystem().getDataType(StructType.class, STRUCT_TYPE_2); } @Test http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/test/java/org/apache/atlas/repository/memory/TraitTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/memory/TraitTest.java b/repository/src/test/java/org/apache/atlas/repository/memory/TraitTest.java index 986d0b3..bfdc8b1 100755 --- a/repository/src/test/java/org/apache/atlas/repository/memory/TraitTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/memory/TraitTest.java @@ -65,15 +65,13 @@ public class TraitTest extends BaseTest { */ @Test public void test1() throws AtlasException { - HierarchicalTypeDefinition A = createTraitTypeDef("A", null, - createRequiredAttrDef("a", DataTypes.INT_TYPE), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE), + HierarchicalTypeDefinition A = createTraitTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE), + createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), createOptionalAttrDef("c", DataTypes.BYTE_TYPE), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableList.<String>of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - HierarchicalTypeDefinition C = createTraitTypeDef("C", ImmutableList.<String>of("A"), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); + HierarchicalTypeDefinition C = + createTraitTypeDef("C", ImmutableList.<String>of("A"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableList.<String>of("B", "C"), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); @@ -155,15 +153,13 @@ public class TraitTest extends BaseTest { @Test public void testRandomOrder() throws AtlasException { - HierarchicalTypeDefinition A = createTraitTypeDef("A", null, - createRequiredAttrDef("a", DataTypes.INT_TYPE), - createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE), + HierarchicalTypeDefinition A = createTraitTypeDef("A", null, createRequiredAttrDef("a", DataTypes.INT_TYPE), + createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE), createOptionalAttrDef("c", DataTypes.BYTE_TYPE), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); HierarchicalTypeDefinition B = createTraitTypeDef("B", ImmutableList.<String>of("A"), createOptionalAttrDef("b", DataTypes.BOOLEAN_TYPE)); - HierarchicalTypeDefinition C = createTraitTypeDef("C", ImmutableList.<String>of("A"), - createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); + HierarchicalTypeDefinition C = + createTraitTypeDef("C", ImmutableList.<String>of("A"), createOptionalAttrDef("c", DataTypes.BYTE_TYPE)); HierarchicalTypeDefinition D = createTraitTypeDef("D", ImmutableList.<String>of("B", "C"), createOptionalAttrDef("d", DataTypes.SHORT_TYPE)); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java ---------------------------------------------------------------------- diff --git a/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java b/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java index 58031ff..c774123 100755 --- a/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java +++ b/repository/src/test/java/org/apache/atlas/repository/typestore/GraphBackedTypeStoreTest.java @@ -23,8 +23,8 @@ import com.tinkerpop.blueprints.Direction; import com.tinkerpop.blueprints.Edge; import com.tinkerpop.blueprints.Vertex; import junit.framework.Assert; -import org.apache.atlas.GraphTransaction; import org.apache.atlas.AtlasException; +import org.apache.atlas.GraphTransaction; import org.apache.atlas.RepositoryMetadataModule; import org.apache.atlas.TestUtils; import org.apache.atlas.repository.graph.GraphHelper; @@ -80,7 +80,7 @@ public class GraphBackedTypeStoreTest { } } - @Test (dependsOnMethods = "testStore") + @Test(dependsOnMethods = "testStore") public void testRestore() throws Exception { TypesDef types = typeStore.restore(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/TypeNotFoundException.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/TypeNotFoundException.java b/typesystem/src/main/java/org/apache/atlas/TypeNotFoundException.java index cf78298..348dd57 100644 --- a/typesystem/src/main/java/org/apache/atlas/TypeNotFoundException.java +++ b/typesystem/src/main/java/org/apache/atlas/TypeNotFoundException.java @@ -38,7 +38,7 @@ public class TypeNotFoundException extends AtlasException { } public TypeNotFoundException(String message, Throwable cause, boolean enableSuppression, - boolean writableStackTrace) { + boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java b/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java index 561d666..213e46c 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java @@ -67,9 +67,8 @@ public class Referenceable extends Struct implements IReferenceableInstance { * @param values */ @InterfaceAudience.Private - public Referenceable(String guid, String typeName, Map<String, Object> values, - List<String> _traitNames, - Map<String, IStruct> _traits) { + public Referenceable(String guid, String typeName, Map<String, Object> values, List<String> _traitNames, + Map<String, IStruct> _traits) { super(typeName, values); id = new Id(guid, 0, typeName); traitNames = ImmutableList.copyOf(_traitNames); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/DownCastStructInstance.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/DownCastStructInstance.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/DownCastStructInstance.java index e2918fe..deb15b5 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/DownCastStructInstance.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/DownCastStructInstance.java @@ -31,8 +31,7 @@ public class DownCastStructInstance implements IStruct { public final DownCastFieldMapping fieldMapping; public final IStruct backingInstance; - public DownCastStructInstance(String typeName, DownCastFieldMapping fieldMapping, - IStruct backingInstance) { + public DownCastStructInstance(String typeName, DownCastFieldMapping fieldMapping, IStruct backingInstance) { this.typeName = typeName; this.fieldMapping = fieldMapping; this.backingInstance = backingInstance; @@ -60,7 +59,7 @@ public class DownCastStructInstance implements IStruct { @Override public Map<String, Object> getValuesMap() throws AtlasException { - Map<String,Object> m = new HashMap<>(); + Map<String, Object> m = new HashMap<>(); for (String attr : fieldMapping.fieldNameMap.keySet()) { m.put(attr, get(attr)); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java index 4d88f02..641146a 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java @@ -70,8 +70,7 @@ public class Id implements ITypedReferenceableInstance { } public String toString() { - return String - .format("(type: %s, id: %s)", className, isUnassigned() ? "<unassigned>" : "" + id); + return String.format("(type: %s, id: %s)", className, isUnassigned() ? "<unassigned>" : "" + id); } public String getClassName() { @@ -88,14 +87,24 @@ public class Id implements ITypedReferenceableInstance { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } Id id1 = (Id) o; - if (version != id1.version) return false; - if (!className.equals(id1.className)) return false; - if (!id.equals(id1.id)) return false; + if (version != id1.version) { + return false; + } + if (!className.equals(id1.className)) { + return false; + } + if (!id.equals(id1.id)) { + return false; + } return true; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/MapIds.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/MapIds.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/MapIds.java index f7e2d76..e62f29d 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/MapIds.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/MapIds.java @@ -59,8 +59,7 @@ public class MapIds implements ObjectGraphWalker.NodeProcessor { } } else if (nd.aInfo.dataType().getTypeCategory() == DataTypes.TypeCategory.ARRAY) { DataTypes.ArrayType aT = (DataTypes.ArrayType) nd.aInfo.dataType(); - Object v = aT - .mapIds((ImmutableCollection) nd.value, nd.aInfo.multiplicity, idToNewIdMap); + Object v = aT.mapIds((ImmutableCollection) nd.value, nd.aInfo.multiplicity, idToNewIdMap); nd.instance.set(nd.attributeName, v); } else if (nd.aInfo.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP) { DataTypes.MapType mT = (DataTypes.MapType) nd.aInfo.dataType(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java index ef11858..911a5f4 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/ReferenceableInstance.java @@ -40,20 +40,12 @@ public class ReferenceableInstance extends StructInstance implements ITypedRefer private Id id; - public ReferenceableInstance(Id id, String dataTypeName, FieldMapping fieldMapping, - boolean[] nullFlags, - boolean[] bools, byte[] bytes, short[] shorts, int[] ints, - long[] longs, - float[] floats, double[] doubles, BigDecimal[] bigDecimals, - BigInteger[] bigIntegers, Date[] dates, String[] strings, - ImmutableList<Object>[] arrays, - ImmutableMap<Object, Object>[] maps, - StructInstance[] structs, - ReferenceableInstance[] referenceableInstances, - Id[] ids, - ImmutableMap<String, ITypedStruct> traits) { - super(dataTypeName, fieldMapping, nullFlags, bools, bytes, shorts, ints, longs, floats, - doubles, bigDecimals, + public ReferenceableInstance(Id id, String dataTypeName, FieldMapping fieldMapping, boolean[] nullFlags, + boolean[] bools, byte[] bytes, short[] shorts, int[] ints, long[] longs, float[] floats, double[] doubles, + BigDecimal[] bigDecimals, BigInteger[] bigIntegers, Date[] dates, String[] strings, + ImmutableList<Object>[] arrays, ImmutableMap<Object, Object>[] maps, StructInstance[] structs, + ReferenceableInstance[] referenceableInstances, Id[] ids, ImmutableMap<String, ITypedStruct> traits) { + super(dataTypeName, fieldMapping, nullFlags, bools, bytes, shorts, ints, longs, floats, doubles, bigDecimals, bigIntegers, dates, strings, arrays, maps, structs, referenceableInstances, ids); this.id = id; this.traits = traits; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java index 73d1141..309ab11 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/StructInstance.java @@ -60,15 +60,11 @@ public class StructInstance implements ITypedStruct { public final ReferenceableInstance[] referenceables; public final Id[] ids; - public StructInstance(String dataTypeName, FieldMapping fieldMapping, - boolean[] nullFlags, boolean[] bools, byte[] bytes, short[] shorts, - int[] ints, - long[] longs, float[] floats, double[] doubles, - BigDecimal[] bigDecimals, BigInteger[] bigIntegers, Date[] dates, - String[] strings, - ImmutableList<Object>[] arrays, ImmutableMap<Object, Object>[] maps, - StructInstance[] structs, ReferenceableInstance[] referenceables, - Id[] ids) { + public StructInstance(String dataTypeName, FieldMapping fieldMapping, boolean[] nullFlags, boolean[] bools, + byte[] bytes, short[] shorts, int[] ints, long[] longs, float[] floats, double[] doubles, + BigDecimal[] bigDecimals, BigInteger[] bigIntegers, Date[] dates, String[] strings, + ImmutableList<Object>[] arrays, ImmutableMap<Object, Object>[] maps, StructInstance[] structs, + ReferenceableInstance[] referenceables, Id[] ids) { assert dataTypeName != null; this.dataTypeName = dataTypeName; this.fieldMapping = fieldMapping; @@ -115,8 +111,7 @@ public class StructInstance implements ITypedStruct { Object cVal = null; if (val != null && val instanceof Id) { - ClassType clsType = - TypeSystem.getInstance().getDataType(ClassType.class, i.dataType().getName()); + ClassType clsType = TypeSystem.getInstance().getDataType(ClassType.class, i.dataType().getName()); clsType.validateId((Id) val); cVal = val; } else { @@ -155,8 +150,8 @@ public class StructInstance implements ITypedStruct { arrays[pos] = (ImmutableList) cVal; } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP) { maps[pos] = (ImmutableMap) cVal; - } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.STRUCT || - i.dataType().getTypeCategory() == DataTypes.TypeCategory.TRAIT) { + } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.STRUCT + || i.dataType().getTypeCategory() == DataTypes.TypeCategory.TRAIT) { structs[pos] = (StructInstance) cVal; } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) { if (cVal instanceof Id) { @@ -172,8 +167,7 @@ public class StructInstance implements ITypedStruct { public Object get(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } int pos = fieldMapping.fieldPos.get(attrName); int nullPos = fieldMapping.fieldNullPos.get(attrName); @@ -210,8 +204,8 @@ public class StructInstance implements ITypedStruct { return arrays[pos]; } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP) { return maps[pos]; - } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.STRUCT || - i.dataType().getTypeCategory() == DataTypes.TypeCategory.TRAIT) { + } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.STRUCT + || i.dataType().getTypeCategory() == DataTypes.TypeCategory.TRAIT) { return structs[pos]; } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) { if (ids[pos] != null) { @@ -227,8 +221,7 @@ public class StructInstance implements ITypedStruct { public void setNull(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } int nullPos = fieldMapping.fieldNullPos.get(attrName); nullFlags[nullPos] = true; @@ -241,7 +234,7 @@ public class StructInstance implements ITypedStruct { @Override public Map<String, Object> getValuesMap() throws AtlasException { - Map<String,Object> m = new HashMap<>(); + Map<String, Object> m = new HashMap<>(); for (String attr : fieldMapping.fields.keySet()) { m.put(attr, get(attr)); } @@ -251,14 +244,13 @@ public class StructInstance implements ITypedStruct { public boolean getBoolean(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BOOLEAN_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.BOOLEAN_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.BOOLEAN_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -274,14 +266,13 @@ public class StructInstance implements ITypedStruct { public byte getByte(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BYTE_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.BYTE_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.BYTE_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -297,14 +288,13 @@ public class StructInstance implements ITypedStruct { public short getShort(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.SHORT_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.SHORT_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.SHORT_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -320,15 +310,14 @@ public class StructInstance implements ITypedStruct { public int getInt(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.INT_TYPE && !(i.dataType() instanceof EnumType)) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.INT_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.INT_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -344,14 +333,13 @@ public class StructInstance implements ITypedStruct { public long getLong(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.LONG_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.LONG_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.LONG_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -367,14 +355,13 @@ public class StructInstance implements ITypedStruct { public float getFloat(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.FLOAT_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.FLOAT_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.FLOAT_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -390,14 +377,13 @@ public class StructInstance implements ITypedStruct { public double getDouble(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.DOUBLE_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.DOUBLE_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.DOUBLE_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -413,14 +399,13 @@ public class StructInstance implements ITypedStruct { public BigInteger getBigInt(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BIGINTEGER_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.BIGINTEGER_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.BIGINTEGER_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -436,14 +421,13 @@ public class StructInstance implements ITypedStruct { public BigDecimal getBigDecimal(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BIGDECIMAL_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.BIGDECIMAL_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.BIGDECIMAL_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -459,14 +443,13 @@ public class StructInstance implements ITypedStruct { public Date getDate(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.DATE_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.DATE_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.DATE_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -482,14 +465,13 @@ public class StructInstance implements ITypedStruct { public String getString(String attrName) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.STRING_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic get method", - attrName, getTypeName(), DataTypes.STRING_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic get method", attrName, + getTypeName(), DataTypes.STRING_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -505,14 +487,13 @@ public class StructInstance implements ITypedStruct { public void setBoolean(String attrName, boolean val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BOOLEAN_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.BOOLEAN_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.BOOLEAN_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -525,14 +506,13 @@ public class StructInstance implements ITypedStruct { public void setByte(String attrName, byte val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BYTE_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.BYTE_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.BYTE_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -545,14 +525,13 @@ public class StructInstance implements ITypedStruct { public void setShort(String attrName, short val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.SHORT_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.SHORT_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.SHORT_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -565,14 +544,13 @@ public class StructInstance implements ITypedStruct { public void setInt(String attrName, int val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.INT_TYPE && !(i.dataType() instanceof EnumType)) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.INT_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.INT_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -585,14 +563,13 @@ public class StructInstance implements ITypedStruct { public void setLong(String attrName, long val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.LONG_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.LONG_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.LONG_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -605,14 +582,13 @@ public class StructInstance implements ITypedStruct { public void setFloat(String attrName, float val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.FLOAT_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.FLOAT_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.FLOAT_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -625,14 +601,13 @@ public class StructInstance implements ITypedStruct { public void setDouble(String attrName, double val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.DOUBLE_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.DOUBLE_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.DOUBLE_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -645,14 +620,13 @@ public class StructInstance implements ITypedStruct { public void setBigInt(String attrName, BigInteger val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BIGINTEGER_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.BIGINTEGER_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.BIGINTEGER_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -665,14 +639,13 @@ public class StructInstance implements ITypedStruct { public void setBigDecimal(String attrName, BigDecimal val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.BIGDECIMAL_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.BIGDECIMAL_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.BIGDECIMAL_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -685,14 +658,13 @@ public class StructInstance implements ITypedStruct { public void setDate(String attrName, Date val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.DATE_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.DATE_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.DATE_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); @@ -705,14 +677,13 @@ public class StructInstance implements ITypedStruct { public void setString(String attrName, String val) throws AtlasException { AttributeInfo i = fieldMapping.fields.get(attrName); if (i == null) { - throw new AtlasException( - String.format("Unknown field %s for Struct %s", attrName, getTypeName())); + throw new AtlasException(String.format("Unknown field %s for Struct %s", attrName, getTypeName())); } if (i.dataType() != DataTypes.STRING_TYPE) { throw new AtlasException( - String.format("Field %s for Struct %s is not a %s, call generic set method", - attrName, getTypeName(), DataTypes.STRING_TYPE.getName())); + String.format("Field %s for Struct %s is not a %s, call generic set method", attrName, + getTypeName(), DataTypes.STRING_TYPE.getName())); } int pos = fieldMapping.fieldPos.get(attrName); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java index e18305f..31b5f47 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java @@ -35,15 +35,14 @@ public final class AttributeDefinition { */ public final String reverseAttributeName; - public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity, - boolean isComposite, String reverseAttributeName) { + public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity, boolean isComposite, + String reverseAttributeName) { this(name, dataTypeName, multiplicity, isComposite, false, true, reverseAttributeName); } - public AttributeDefinition(String name, String dataTypeName, - Multiplicity multiplicity, boolean isComposite, boolean isUnique, - boolean isIndexable, String reverseAttributeName) { + public AttributeDefinition(String name, String dataTypeName, Multiplicity multiplicity, boolean isComposite, + boolean isUnique, boolean isIndexable, String reverseAttributeName) { this.name = ParamChecker.notEmpty(name, "Attribute name"); this.dataTypeName = ParamChecker.notEmpty(dataTypeName, "Attribute type"); this.multiplicity = multiplicity; @@ -55,21 +54,37 @@ public final class AttributeDefinition { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } AttributeDefinition that = (AttributeDefinition) o; - if (isComposite != that.isComposite) return false; - if (isUnique != that.isUnique) return false; - if (isIndexable != that.isIndexable) return false; - if (!dataTypeName.equals(that.dataTypeName)) return false; - if (!multiplicity.equals(that.multiplicity)) return false; - if (!name.equals(that.name)) return false; - if (reverseAttributeName != null - ? !reverseAttributeName.equals(that.reverseAttributeName) - : that.reverseAttributeName != null) + if (isComposite != that.isComposite) { + return false; + } + if (isUnique != that.isUnique) { + return false; + } + if (isIndexable != that.isIndexable) { + return false; + } + if (!dataTypeName.equals(that.dataTypeName)) { + return false; + } + if (!multiplicity.equals(that.multiplicity)) { + return false; + } + if (!name.equals(that.name)) { + return false; + } + if (reverseAttributeName != null ? !reverseAttributeName.equals(that.reverseAttributeName) : + that.reverseAttributeName != null) { return false; + } return true; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java index 78be050..e74f8d5 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java @@ -39,8 +39,9 @@ public class AttributeInfo { AttributeInfo(TypeSystem t, AttributeDefinition def, Map<String, IDataType> tempTypes) throws AtlasException { this.name = def.name; - this.dataType = (tempTypes != null && tempTypes.containsKey(def.dataTypeName)) ? - tempTypes.get(def.dataTypeName) : t.getDataType(IDataType.class, def.dataTypeName); + this.dataType = + (tempTypes != null && tempTypes.containsKey(def.dataTypeName)) ? tempTypes.get(def.dataTypeName) : + t.getDataType(IDataType.class, def.dataTypeName); this.multiplicity = def.multiplicity; this.isComposite = def.isComposite; this.isUnique = def.isUnique; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java index c9fc094..cdfbf07 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java @@ -53,8 +53,7 @@ public class ClassType extends HierarchicalType<ClassType, IReferenceableInstanc infoToNameMap = null; } - ClassType(TypeSystem typeSystem, String name, ImmutableList<String> superTypes, - AttributeInfo... fields) + ClassType(TypeSystem typeSystem, String name, ImmutableList<String> superTypes, AttributeInfo... fields) throws AtlasException { super(typeSystem, ClassType.class, name, superTypes, fields); infoToNameMap = TypeUtils.buildAttrInfoToNameMap(fieldMapping); @@ -71,8 +70,7 @@ public class ClassType extends HierarchicalType<ClassType, IReferenceableInstanc if (isSubType(cType.getName())) { return; } - throw new AtlasException( - String.format("Id %s is not valid for class %s", id, getName())); + throw new AtlasException(String.format("Id %s is not valid for class %s", id, getName())); } } @@ -84,8 +82,7 @@ public class ClassType extends HierarchicalType<ClassType, IReferenceableInstanc } @Override - public ITypedReferenceableInstance convert(Object val, Multiplicity m) - throws AtlasException { + public ITypedReferenceableInstance convert(Object val, Multiplicity m) throws AtlasException { if (val != null) { if (val instanceof ITypedReferenceableInstance) { @@ -122,9 +119,9 @@ public class ClassType extends HierarchicalType<ClassType, IReferenceableInstanc id = r.getId(); } - ITypedReferenceableInstance tr = r != null ? - createInstanceWithTraits(id, r, r.getTraits().toArray(new String[0])) - : createInstance(id); + ITypedReferenceableInstance tr = + r != null ? createInstanceWithTraits(id, r, r.getTraits().toArray(new String[0])) : + createInstance(id); if (id != null && id.isAssigned()) { return tr; @@ -134,8 +131,7 @@ public class ClassType extends HierarchicalType<ClassType, IReferenceableInstanc String attrKey = e.getKey(); AttributeInfo i = e.getValue(); Object aVal = s.get(attrKey); - if (aVal != null && - i.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) { + if (aVal != null && i.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) { if (!i.isComposite) { aVal = ((IReferenceableInstance) aVal).getId(); } @@ -164,25 +160,21 @@ public class ClassType extends HierarchicalType<ClassType, IReferenceableInstanc @Override public ITypedReferenceableInstance createInstance() throws AtlasException { - return createInstance((String[])null); + return createInstance((String[]) null); } - public ITypedReferenceableInstance createInstance(String... traitNames) - throws AtlasException { + public ITypedReferenceableInstance createInstance(String... traitNames) throws AtlasException { return createInstance(null, traitNames); } - public ITypedReferenceableInstance createInstance(Id id, String... traitNames) - throws AtlasException { + public ITypedReferenceableInstance createInstance(Id id, String... traitNames) throws AtlasException { return createInstanceWithTraits(id, null, traitNames); } - public ITypedReferenceableInstance createInstanceWithTraits(Id id, Referenceable r, - String... traitNames) + public ITypedReferenceableInstance createInstanceWithTraits(Id id, Referenceable r, String... traitNames) throws AtlasException { - ImmutableMap.Builder<String, ITypedStruct> b - = new ImmutableBiMap.Builder<String, ITypedStruct>(); + ImmutableMap.Builder<String, ITypedStruct> b = new ImmutableBiMap.Builder<String, ITypedStruct>(); if (traitNames != null) { for (String t : traitNames) { TraitType tType = typeSystem.getDataType(TraitType.class, t); @@ -193,9 +185,7 @@ public class ClassType extends HierarchicalType<ClassType, IReferenceableInstanc } } - return new ReferenceableInstance(id == null ? new Id(getName()) : id, - getName(), - fieldMapping, + return new ReferenceableInstance(id == null ? new Id(getName()) : id, getName(), fieldMapping, new boolean[fieldMapping.fields.size()], fieldMapping.numBools == 0 ? null : new boolean[fieldMapping.numBools], fieldMapping.numBytes == 0 ? null : new byte[fieldMapping.numBytes], @@ -204,23 +194,19 @@ public class ClassType extends HierarchicalType<ClassType, IReferenceableInstanc fieldMapping.numLongs == 0 ? null : new long[fieldMapping.numLongs], fieldMapping.numFloats == 0 ? null : new float[fieldMapping.numFloats], fieldMapping.numDoubles == 0 ? null : new double[fieldMapping.numDoubles], - fieldMapping.numBigDecimals == 0 ? null - : new BigDecimal[fieldMapping.numBigDecimals], + fieldMapping.numBigDecimals == 0 ? null : new BigDecimal[fieldMapping.numBigDecimals], fieldMapping.numBigInts == 0 ? null : new BigInteger[fieldMapping.numBigInts], fieldMapping.numDates == 0 ? null : new Date[fieldMapping.numDates], fieldMapping.numStrings == 0 ? null : new String[fieldMapping.numStrings], fieldMapping.numArrays == 0 ? null : new ImmutableList[fieldMapping.numArrays], fieldMapping.numMaps == 0 ? null : new ImmutableMap[fieldMapping.numMaps], fieldMapping.numStructs == 0 ? null : new StructInstance[fieldMapping.numStructs], - fieldMapping.numReferenceables == 0 ? null - : new ReferenceableInstance[fieldMapping.numReferenceables], - fieldMapping.numReferenceables == 0 ? null : new Id[fieldMapping.numReferenceables], - b.build()); + fieldMapping.numReferenceables == 0 ? null : new ReferenceableInstance[fieldMapping.numReferenceables], + fieldMapping.numReferenceables == 0 ? null : new Id[fieldMapping.numReferenceables], b.build()); } @Override - public void output(IReferenceableInstance s, Appendable buf, String prefix) - throws AtlasException { + public void output(IReferenceableInstance s, Appendable buf, String prefix) throws AtlasException { fieldMapping.output(s, buf, prefix); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java index 53cfc96..5fc6c1b 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java @@ -62,8 +62,7 @@ public class DataTypes { } public static String mapTypeName(String keyTypeName, String valueTypeName) { - return String.format("%s%s,%s%s", MAP_TYPE_PREFIX, - keyTypeName, valueTypeName, MAP_TYPE_SUFFIX); + return String.format("%s%s,%s%s", MAP_TYPE_PREFIX, keyTypeName, valueTypeName, MAP_TYPE_SUFFIX); } public static String mapTypeName(IDataType keyType, IDataType valueType) { @@ -433,8 +432,8 @@ public class DataTypes { @Override public void output(Date val, Appendable buf, String prefix) throws AtlasException { - TypeUtils.outputVal(val == null ? "<null>" : - TypeSystem.getInstance().getDateFormat().format(val), buf, prefix); + TypeUtils.outputVal(val == null ? "<null>" : TypeSystem.getInstance().getDateFormat().format(val), buf, + prefix); } public Date nullValue() { @@ -502,19 +501,18 @@ public class DataTypes { it = (Iterator) val; } if (it != null) { - ImmutableCollection.Builder b = m.isUnique ? ImmutableSet.builder() - : ImmutableList.builder(); + ImmutableCollection.Builder b = m.isUnique ? ImmutableSet.builder() : ImmutableList.builder(); while (it.hasNext()) { b.add(elemType.convert(it.next(), - TypeSystem.getInstance().allowNullsInCollections() - ? Multiplicity.OPTIONAL : Multiplicity.REQUIRED)); + TypeSystem.getInstance().allowNullsInCollections() ? Multiplicity.OPTIONAL : + Multiplicity.REQUIRED)); } return m.isUnique ? b.build().asList() : b.build(); } else { try { return ImmutableList.of(elemType.convert(val, - TypeSystem.getInstance().allowNullsInCollections() - ? Multiplicity.OPTIONAL : Multiplicity.REQUIRED)); + TypeSystem.getInstance().allowNullsInCollections() ? Multiplicity.OPTIONAL : + Multiplicity.REQUIRED)); } catch (Exception e) { throw new ValueConversionException(this, val, e); } @@ -526,15 +524,13 @@ public class DataTypes { return null; } - public ImmutableCollection<?> mapIds(ImmutableCollection<?> val, Multiplicity m, - Map<Id, Id> transientToNewIds) + public ImmutableCollection<?> mapIds(ImmutableCollection<?> val, Multiplicity m, Map<Id, Id> transientToNewIds) throws AtlasException { if (val == null || elemType.getTypeCategory() != TypeCategory.CLASS) { return val; } - ImmutableCollection.Builder b = m.isUnique ? ImmutableSet.builder() - : ImmutableList.builder(); + ImmutableCollection.Builder b = m.isUnique ? ImmutableSet.builder() : ImmutableList.builder(); Iterator it = val.iterator(); while (it.hasNext()) { Object elem = it.next(); @@ -600,11 +596,10 @@ public class DataTypes { while (it.hasNext()) { Map.Entry e = it.next(); b.put(keyType.convert(e.getKey(), - TypeSystem.getInstance().allowNullsInCollections() - ? Multiplicity.OPTIONAL : Multiplicity.REQUIRED), - valueType.convert(e.getValue(), - TypeSystem.getInstance().allowNullsInCollections() - ? Multiplicity.OPTIONAL : Multiplicity.REQUIRED)); + TypeSystem.getInstance().allowNullsInCollections() ? Multiplicity.OPTIONAL : + Multiplicity.REQUIRED), valueType.convert(e.getValue(), + TypeSystem.getInstance().allowNullsInCollections() ? Multiplicity.OPTIONAL : + Multiplicity.REQUIRED)); } return b.build(); } else { @@ -617,12 +612,11 @@ public class DataTypes { return null; } - public ImmutableMap<?, ?> mapIds(ImmutableMap val, Multiplicity m, - Map<Id, Id> transientToNewIds) + public ImmutableMap<?, ?> mapIds(ImmutableMap val, Multiplicity m, Map<Id, Id> transientToNewIds) throws AtlasException { - if (val == null || (keyType.getTypeCategory() != TypeCategory.CLASS && - valueType.getTypeCategory() != TypeCategory.CLASS)) { + if (val == null || (keyType.getTypeCategory() != TypeCategory.CLASS + && valueType.getTypeCategory() != TypeCategory.CLASS)) { return val; } ImmutableMap.Builder b = ImmutableMap.builder(); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/DownCastFieldMapping.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DownCastFieldMapping.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DownCastFieldMapping.java index d198a81..85e288e 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DownCastFieldMapping.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/DownCastFieldMapping.java @@ -30,8 +30,7 @@ public class DownCastFieldMapping { this.fieldNameMap = fieldNameMap; } - public void set(DownCastStructInstance s, String attrName, Object val) - throws AtlasException { + public void set(DownCastStructInstance s, String attrName, Object val) throws AtlasException { String mappedNm = fieldNameMap.get(attrName); if (mappedNm == null) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java index 38ca6b8..f6927da 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java @@ -54,13 +54,13 @@ public class EnumType extends AbstractDataType<EnumValue> { if (val != null) { EnumValue e = null; if (val instanceof EnumValue) { - e = valueMap.get(((EnumValue)val).value); - } else if ( val instanceof Integer || val instanceof BigInt) { + e = valueMap.get(((EnumValue) val).value); + } else if (val instanceof Integer || val instanceof BigInt) { e = ordinalMap.get(val); - } else if ( val instanceof String) { + } else if (val instanceof String) { e = valueMap.get(val); - } else if ( val instanceof Number ) { - e = ordinalMap.get(((Number)val).intValue()); + } else if (val instanceof Number) { + e = ordinalMap.get(((Number) val).intValue()); } if (e == null) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java index 15be1db..7afc52e 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java @@ -34,13 +34,21 @@ public final class EnumTypeDefinition { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } EnumTypeDefinition that = (EnumTypeDefinition) o; - if (!Arrays.equals(enumValues, that.enumValues)) return false; - if (!name.equals(that.name)) return false; + if (!Arrays.equals(enumValues, that.enumValues)) { + return false; + } + if (!name.equals(that.name)) { + return false; + } return true; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumValue.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumValue.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumValue.java index 309257c..d22e7e0 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumValue.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumValue.java @@ -32,13 +32,21 @@ public class EnumValue { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } EnumValue enumValue = (EnumValue) o; - if (ordinal != enumValue.ordinal) return false; - if (!value.equals(enumValue.value)) return false; + if (ordinal != enumValue.ordinal) { + return false; + } + if (!value.equals(enumValue.value)) { + return false; + } return true; } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/FieldMapping.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/FieldMapping.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/FieldMapping.java index fec54e8..36149ba 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/FieldMapping.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/FieldMapping.java @@ -47,12 +47,9 @@ public class FieldMapping { public final int numReferenceables; public FieldMapping(Map<String, AttributeInfo> fields, Map<String, Integer> fieldPos, - Map<String, Integer> fieldNullPos, int numBools, int numBytes, - int numShorts, - int numInts, int numLongs, int numFloats, int numDoubles, int numBigInts, - int numBigDecimals, - int numDates, int numStrings, int numArrays, int numMaps, int numStructs, - int numReferenceables) { + Map<String, Integer> fieldNullPos, int numBools, int numBytes, int numShorts, int numInts, int numLongs, + int numFloats, int numDoubles, int numBigInts, int numBigDecimals, int numDates, int numStrings, + int numArrays, int numMaps, int numStructs, int numReferenceables) { this.fields = fields; this.fieldPos = fieldPos; this.fieldNullPos = fieldNullPos; @@ -73,8 +70,7 @@ public class FieldMapping { this.numReferenceables = numReferenceables; } - protected void outputFields(IStruct s, Appendable buf, String fieldPrefix) - throws AtlasException { + protected void outputFields(IStruct s, Appendable buf, String fieldPrefix) throws AtlasException { for (Map.Entry<String, AttributeInfo> e : fields.entrySet()) { String attrName = e.getKey(); AttributeInfo i = e.getValue(); @@ -104,8 +100,7 @@ public class FieldMapping { TypeUtils.outputVal("}", buf, prefix); } - public void output(IReferenceableInstance s, Appendable buf, String prefix) - throws AtlasException { + public void output(IReferenceableInstance s, Appendable buf, String prefix) throws AtlasException { if (s == null) { TypeUtils.outputVal("<null>\n", buf, ""); return; http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/fef50cee/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java index 57ea0b8..80c6c01 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java @@ -61,8 +61,8 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A /** * Used when creating a Type, to support recursive Structs. */ - HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, - String name, ImmutableList<String> superTypes, int numFields) { + HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, String name, ImmutableList<String> superTypes, + int numFields) { this.typeSystem = typeSystem; this.superTypeClass = superTypeClass; this.name = name; @@ -73,14 +73,12 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A this.attributeNameToType = null; } - HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, - String name, ImmutableList<String> superTypes, AttributeInfo... fields) - throws AtlasException { + HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, String name, ImmutableList<String> superTypes, + AttributeInfo... fields) throws AtlasException { this.typeSystem = typeSystem; this.superTypeClass = superTypeClass; this.name = name; - Pair<FieldMapping, ImmutableMap<String, String>> p = constructFieldMapping(superTypes, - fields); + Pair<FieldMapping, ImmutableMap<String, String>> p = constructFieldMapping(superTypes, fields); this.fieldMapping = p.left; this.attributeNameToType = p.right; this.numFields = this.fieldMapping.fields.size(); @@ -107,13 +105,11 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A return (cType == this || cType.superTypePaths.containsKey(getName())); } - protected void setupSuperTypesGraph() - throws AtlasException { + protected void setupSuperTypesGraph() throws AtlasException { setupSuperTypesGraph(superTypes); } - private void setupSuperTypesGraph(ImmutableList<String> superTypes) - throws AtlasException { + private void setupSuperTypesGraph(ImmutableList<String> superTypes) throws AtlasException { Map<String, List<Path>> superTypePaths = new HashMap<String, List<Path>>(); Map<String, Path> pathNameToPathMap = new HashMap<String, Path>(); Queue<Path> queue = new LinkedList<Path>(); @@ -149,8 +145,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A } protected Pair<FieldMapping, ImmutableMap<String, String>> constructFieldMapping(ImmutableList<String> superTypes, - AttributeInfo... fields) - throws AtlasException { + AttributeInfo... fields) throws AtlasException { Map<String, AttributeInfo> fieldsMap = new LinkedHashMap<String, AttributeInfo>(); Map<String, Integer> fieldPos = new HashMap<String, Integer>(); @@ -182,19 +177,16 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A ST superType = currentPath.typeName == getName() ? (ST) this : (ST) typeSystem.getDataType(superTypeClass, currentPath.typeName); - ImmutableList<AttributeInfo> superTypeFields = superType == this ? - ImmutableList.copyOf(fields) : superType.immediateAttrs; + ImmutableList<AttributeInfo> superTypeFields = + superType == this ? ImmutableList.copyOf(fields) : superType.immediateAttrs; Set<String> immediateFields = new HashSet<String>(); for (AttributeInfo i : superTypeFields) { if (superType == this) { if (immediateFields.contains(i.name)) { - throw new AtlasException( - String.format( - "Struct defintion cannot contain multiple fields with the" + - " same name %s", - i.name)); + throw new AtlasException(String.format( + "Struct defintion cannot contain multiple fields with the" + " same name %s", i.name)); } immediateFields.add(i.name); } @@ -249,8 +241,8 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.MAP) { fieldPos.put(attrName, numMaps); numMaps++; - } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.STRUCT || - i.dataType().getTypeCategory() == DataTypes.TypeCategory.TRAIT) { + } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.STRUCT + || i.dataType().getTypeCategory() == DataTypes.TypeCategory.TRAIT) { fieldPos.put(attrName, numStructs); numStructs++; } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) { @@ -265,24 +257,10 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A this.superTypePaths = ImmutableMap.copyOf(superTypePaths); this.pathNameToPathMap = ImmutableMap.copyOf(pathNameToPathMap); - FieldMapping fm = new FieldMapping(fieldsMap, - fieldPos, - fieldNullPos, - numBools, - numBytes, - numShorts, - numInts, - numLongs, - numFloats, - numDoubles, - numBigInts, - numBigDecimals, - numDates, - numStrings, - numArrays, - numMaps, - numStructs, - numReferenceables); + FieldMapping fm = + new FieldMapping(fieldsMap, fieldPos, fieldNullPos, numBools, numBytes, numShorts, numInts, numLongs, + numFloats, numDoubles, numBigInts, numBigDecimals, numDates, numStrings, numArrays, numMaps, + numStructs, numReferenceables); return new Pair(fm, ImmutableMap.copyOf(attributeNameToType)); } @@ -290,31 +268,26 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A public IStruct castAs(IStruct s, String superTypeName) throws AtlasException { if (!superTypePaths.containsKey(superTypeName)) { - throw new AtlasException( - String.format("Cannot downcast to %s from type %s", superTypeName, getName())); + throw new AtlasException(String.format("Cannot downcast to %s from type %s", superTypeName, getName())); } if (s != null) { if (s.getTypeName() != getName()) { throw new AtlasException( - String.format("Downcast called on wrong type %s, instance type is %s", - getName(), s.getTypeName())); + String.format("Downcast called on wrong type %s, instance type is %s", getName(), + s.getTypeName())); } List<Path> pathToSuper = superTypePaths.get(superTypeName); if (pathToSuper.size() > 1) { - throw new AtlasException( - String.format( - "Cannot downcast called to %s, from %s: there are multiple paths " + - "to SuperType", - superTypeName, getName())); + throw new AtlasException(String.format( + "Cannot downcast called to %s, from %s: there are multiple paths " + "to SuperType", + superTypeName, getName())); } ST superType = (ST) typeSystem.getDataType(superTypeClass, superTypeName); - Map<String, String> downCastMap = superType - .constructDowncastFieldMap(this, pathToSuper.get(0)); - return new DownCastStructInstance(superTypeName, - new DownCastFieldMapping(ImmutableMap.copyOf(downCastMap)), + Map<String, String> downCastMap = superType.constructDowncastFieldMap(this, pathToSuper.get(0)); + return new DownCastStructInstance(superTypeName, new DownCastFieldMapping(ImmutableMap.copyOf(downCastMap)), s); } @@ -347,14 +320,12 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A Iterator<Path> itr = pathIterator(); while (itr.hasNext()) { Path p = itr.next(); - Path pInSubType = (Path) subType.pathNameToPathMap - .get(p.pathName + "." + pathToSubTypeName); + Path pInSubType = (Path) subType.pathNameToPathMap.get(p.pathName + "." + pathToSubTypeName); if (pInSubType.hiddenAttributeMap != null) { for (Map.Entry<String, String> e : pInSubType.hiddenAttributeMap.entrySet()) { String mappedInThisType = - p.hiddenAttributeMap != null ? p.hiddenAttributeMap.get(e.getKey()) - : null; + p.hiddenAttributeMap != null ? p.hiddenAttributeMap.get(e.getKey()) : null; if (mappedInThisType == null) { dCMap.put(e.getKey(), e.getValue()); } else { @@ -393,8 +364,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A private final Path subTypePath; /* * name mapping for attributes hidden by a SubType. - */ - Map<String, String> hiddenAttributeMap; + */ Map<String, String> hiddenAttributeMap; Path(String typeName, Path childPath) throws AtlasException { this.typeName = typeName; @@ -415,8 +385,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A } public boolean contains(String typeName) { - return this.typeName.equals(typeName) || - (subTypePath != null && subTypePath.contains(typeName)); + return this.typeName.equals(typeName) || (subTypePath != null && subTypePath.contains(typeName)); } public String pathString(String nodeSep) { @@ -435,8 +404,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A } String addOverrideAttr(String name) { - hiddenAttributeMap = hiddenAttributeMap == null ? new HashMap<String, String>() - : hiddenAttributeMap; + hiddenAttributeMap = hiddenAttributeMap == null ? new HashMap<String, String>() : hiddenAttributeMap; String oName = pathName + "." + name; hiddenAttributeMap.put(name, oName); return oName;
