You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2017/11/05 20:31:31 UTC

[09/40] atlas git commit: ATLAS-2251: Remove TypeSystem and related implementation, to avoid unncessary duplicate of type details in cache

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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
deleted file mode 100755
index c24a55f..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import org.apache.atlas.AtlasException;
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-public class AttributeInfo {
-    public final String name;
-    public final Multiplicity multiplicity;
-    //A composite is the one whose lifecycle is dependent on the enclosing type and is not just a reference
-    public final boolean isComposite;
-    public final boolean isUnique;
-    public final boolean isIndexable;
-    /**
-     * If this is a reference attribute, then the name of the attribute on the Class
-     * that this refers to.
-     */
-    public final String reverseAttributeName;
-    private IDataType dataType;
-
-    public 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.multiplicity = def.multiplicity;
-        this.isComposite = def.isComposite;
-        this.isUnique = def.isUnique;
-        this.isIndexable = def.isIndexable;
-        this.reverseAttributeName = def.reverseAttributeName;
-    }
-
-    public IDataType dataType() {
-        return dataType;
-    }
-
-    void setDataType(IDataType dT) {
-        dataType = dT;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder buf = new StringBuilder();
-        try {
-            output(buf, new HashSet<String>());
-        } catch (AtlasException e) {
-            throw new RuntimeException(e);
-        }
-        return buf.toString();
-    }
-
-    public void output(Appendable buf, Set<String> typesInProcess) throws AtlasException {
-        try {
-            buf.append("{name=").append(name);
-            buf.append(", dataType=");
-            dataType.output(buf, typesInProcess);
-            buf.append(", multiplicity=").append(multiplicity.toString());
-            buf.append(", isComposite=").append(Boolean.toString(isComposite));
-            buf.append(", isUnique=").append(Boolean.toString(isUnique));
-            buf.append(", isIndexable=").append(Boolean.toString(isIndexable));
-            buf.append(", reverseAttributeName=").append(reverseAttributeName);
-            buf.append('}');
-        }
-        catch(IOException e) {
-            throw new AtlasException(e);
-        }
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(name, multiplicity, isComposite, isUnique, isIndexable, reverseAttributeName, dataType);
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        AttributeInfo that = (AttributeInfo) o;
-        return isComposite == that.isComposite &&
-                isUnique == that.isUnique &&
-                isIndexable == that.isIndexable &&
-                Objects.equals(name, that.name) &&
-                Objects.equals(multiplicity, that.multiplicity) &&
-                Objects.equals(reverseAttributeName, that.reverseAttributeName) &&
-                dataType == null ? that.dataType == null : Objects.equals(dataType.getName(), that.dataType.getName());
-    }
-
-    public String toJson() throws JSONException {
-        JSONObject json = new JSONObject();
-        json.put("name", name);
-        json.put("multiplicity", multiplicity.toJson());
-        json.put("isComposite", isComposite);
-        json.put("isUnique", isUnique);
-        json.put("isIndexable", isIndexable);
-        json.put("dataType", dataType.getName());
-        json.put("reverseAttributeName", reverseAttributeName);
-        return json.toString();
-    }
-
-    public static AttributeDefinition fromJson(String jsonStr) throws JSONException {
-        JSONObject json = new JSONObject(jsonStr);
-        String reverseAttr = null;
-        if (json.has("reverseAttributeName")) {
-            reverseAttr = json.getString("reverseAttributeName");
-        }
-        return new AttributeDefinition(json.getString("name"), json.getString("dataType"),
-                Multiplicity.fromJson(json.getString("multiplicity")), json.getBoolean("isComposite"),
-                json.getBoolean("isUnique"), json.getBoolean("isIndexable"), reverseAttr);
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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
deleted file mode 100755
index 2f2b090..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/ClassType.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import com.google.common.collect.ImmutableBiMap;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
-import org.apache.atlas.AtlasConstants;
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.ITypedReferenceableInstance;
-import org.apache.atlas.typesystem.ITypedStruct;
-import org.apache.atlas.typesystem.Referenceable;
-import org.apache.atlas.typesystem.Struct;
-import org.apache.atlas.typesystem.persistence.AtlasSystemAttributes;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.atlas.typesystem.persistence.ReferenceableInstance;
-import org.apache.atlas.typesystem.persistence.StructInstance;
-import scala.tools.cmd.gen.AnyVals;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.charset.Charset;
-import java.security.MessageDigest;
-import java.util.*;
-
-public class ClassType extends HierarchicalType<ClassType, IReferenceableInstance>
-        implements IConstructableType<IReferenceableInstance, ITypedReferenceableInstance> {
-
-    public static final String TRAIT_NAME_SEP = "::";
-
-    public final Map<AttributeInfo, List<String>> infoToNameMap;
-
-    ClassType(TypeSystem typeSystem, String name, String description, ImmutableSet<String> superTypes, int numFields) {
-        this(typeSystem, name, description, AtlasConstants.DEFAULT_TYPE_VERSION, superTypes, numFields);
-    }
-
-    ClassType(TypeSystem typeSystem, String name, String description, String version, ImmutableSet<String> superTypes, int numFields) {
-        super(typeSystem, ClassType.class, name, description, version, superTypes, numFields);
-        infoToNameMap = null;
-    }
-
-    ClassType(TypeSystem typeSystem, String name, String description, ImmutableSet<String> superTypes, AttributeInfo... fields)
-    throws AtlasException {
-        this(typeSystem, name, description, AtlasConstants.DEFAULT_TYPE_VERSION, superTypes, fields);
-    }
-
-    ClassType(TypeSystem typeSystem, String name, String description, String version, ImmutableSet<String> superTypes, AttributeInfo... fields)
-            throws AtlasException {
-        super(typeSystem, ClassType.class, name, description, version, superTypes, fields);
-        infoToNameMap = TypeUtils.buildAttrInfoToNameMap(fieldMapping);
-    }
-
-    @Override
-    public DataTypes.TypeCategory getTypeCategory() {
-        return DataTypes.TypeCategory.CLASS;
-    }
-
-    public void validateId(Id id) throws AtlasException {
-        if (id != null) {
-            ClassType cType = typeSystem.getDataType(ClassType.class, id.typeName);
-            if (isSubType(cType.getName())) {
-                return;
-            }
-            throw new AtlasException(String.format("Id %s is not valid for class %s", id, getName()));
-        }
-    }
-
-    protected Id getId(Object val) throws AtlasException {
-        if (val instanceof Referenceable) {
-            return ((Referenceable) val).getId();
-        }
-        throw new AtlasException(String.format("Cannot get id from class %s", val.getClass()));
-    }
-
-    @Override
-    public ITypedReferenceableInstance convert(Object val, Multiplicity m) throws AtlasException {
-
-        if (val != null) {
-            if (val instanceof ITypedReferenceableInstance) {
-                ITypedReferenceableInstance tr = (ITypedReferenceableInstance) val;
-                if (!tr.getTypeName().equals(getName())) {
-                     /*
-                     * If val is a subType instance; invoke convert on it.
-                     */
-                    ClassType valType = typeSystem.getDataType(superTypeClass, tr.getTypeName());
-                    if (valType.superTypePaths.containsKey(name)) {
-                        return valType.convert(val, m);
-                    }
-                    throw new ValueConversionException(this, val);
-                }
-                return tr;
-            } else if (val instanceof Struct) {
-                Struct s = (Struct) val;
-                Referenceable r = null;
-                Id id = null;
-
-                if (!s.typeName.equals(getName())) {
-                    /*
-                     * If val is a subType instance; invoke convert on it.
-                     */
-                    ClassType valType = typeSystem.getDataType(superTypeClass, s.typeName);
-                    if (valType.superTypePaths.containsKey(name)) {
-                        return valType.convert(s, m);
-                    }
-                    throw new ValueConversionException(this, val);
-                }
-
-                if (val instanceof Referenceable) {
-                    r = (Referenceable) val;
-                    id = r.getId();
-                }
-
-                ITypedReferenceableInstance tr =
-                        r != null ? createInstanceWithTraits(id, null, r, r.getTraits().toArray(new String[0])) :
-                                createInstance(id);
-
-                if (id != null && id.isAssigned()) {
-                    return tr;
-                }
-
-                for (Map.Entry<String, AttributeInfo> e : fieldMapping.fields.entrySet()) {
-                    String attrKey = e.getKey();
-                    AttributeInfo i = e.getValue();
-                    Object aVal = s.get(attrKey);
-                    if (aVal != null && i.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) {
-                        if (!i.isComposite) {
-                            aVal = ((IReferenceableInstance) aVal).getId();
-                        }
-                    }
-
-                    if(!i.multiplicity.nullAllowed() && !s.getValuesMap().containsKey(attrKey)){
-                        throw new ValueConversionException.NullConversionException(i.multiplicity,
-                                String.format(" Value expected for required attribute %s", i.name));
-                    } else {
-                        try {
-                            if (s.getValuesMap().containsKey(attrKey)) {
-                                tr.set(attrKey, aVal);
-                            }
-                        } catch (ValueConversionException ve) {
-                            throw new ValueConversionException(this, val, ve);
-                        }
-                    }
-                }
-
-                return tr;
-            } else if (val instanceof ReferenceableInstance) {
-                validateId(((ReferenceableInstance) val).getId());
-                return (ReferenceableInstance) val;
-            } else {
-                throw new ValueConversionException(this, val, "value's class is " + val.getClass().getName());
-            }
-        }
-        if (!m.nullAllowed()) {
-            throw new ValueConversionException.NullConversionException(m);
-        }
-        return null;
-    }
-
-    @Override
-    public ITypedReferenceableInstance createInstance() throws AtlasException {
-        return createInstance((String[]) null);
-    }
-
-    public ITypedReferenceableInstance createInstance(String... traitNames) throws AtlasException {
-        return createInstance(null, traitNames);
-    }
-
-    public ITypedReferenceableInstance createInstance(Id id, String... traitNames) throws AtlasException {
-        return createInstanceWithTraits(id, null, null, traitNames);
-    }
-
-    public ITypedReferenceableInstance createInstance(Id id, AtlasSystemAttributes systemAttributes, String... traitNames) throws AtlasException{
-        return createInstanceWithTraits(id, systemAttributes, null, traitNames);
-    }
-
-    public ITypedReferenceableInstance createInstanceWithTraits(Id id, AtlasSystemAttributes systemAttributes, Referenceable r, String... traitNames)
-    throws AtlasException {
-
-        ImmutableMap.Builder<String, ITypedStruct> b = new ImmutableBiMap.Builder<>();
-        if (traitNames != null) {
-            for (String t : traitNames) {
-                TraitType tType = typeSystem.getDataType(TraitType.class, t);
-                IStruct iTraitObject = r == null ? null : r.getTrait(t);
-                ITypedStruct trait = iTraitObject == null ? tType.createInstance() :
-                        tType.convert(iTraitObject, Multiplicity.REQUIRED);
-                b.put(t, trait);
-            }
-        }
-
-        return new ReferenceableInstance(id == null ? new Id(getName()) : id, getName(), systemAttributes, fieldMapping,
-                new boolean[fieldMapping.fields.size()], new boolean[fieldMapping.fields.size()],
-                fieldMapping.numBools == 0 ? null : new boolean[fieldMapping.numBools],
-                fieldMapping.numBytes == 0 ? null : new byte[fieldMapping.numBytes],
-                fieldMapping.numShorts == 0 ? null : new short[fieldMapping.numShorts],
-                fieldMapping.numInts == 0 ? null : new int[fieldMapping.numInts],
-                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.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());
-    }
-
-    @Override
-    public void output(IReferenceableInstance s, Appendable buf, String prefix, Set<IReferenceableInstance> inProcess) throws AtlasException {
-        fieldMapping.output(s, buf, prefix, inProcess);
-    }
-
-    @Override
-    public List<String> getNames(AttributeInfo info) {
-        return infoToNameMap.get(info);
-    }
-
-    @Override
-    public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException {
-        if( !(val instanceof  ITypedReferenceableInstance)) {
-            throw new IllegalArgumentException("Unexpected value type " + val.getClass().getSimpleName() + ". Expected instance of ITypedStruct");
-        }
-        digester.update(getName().getBytes(Charset.forName("UTF-8")));
-
-        if(fieldMapping.fields != null && val != null) {
-            IReferenceableInstance typedValue = (IReferenceableInstance) val;
-            if(fieldMapping.fields.values() != null) {
-                for (AttributeInfo aInfo : fieldMapping.fields.values()) {
-                    Object attrVal = typedValue.get(aInfo.name);
-                    if (attrVal != null) {
-                        aInfo.dataType().updateSignatureHash(digester, attrVal);
-                    }
-                }
-            }
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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
deleted file mode 100755
index f9f4abe..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DataTypes.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import com.google.common.collect.ImmutableCollection;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.persistence.Id;
-import org.apache.commons.lang3.StringUtils;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.format.DateTimeFormatter;
-import org.joda.time.format.ISODateTimeFormat;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.charset.Charset;
-import java.security.MessageDigest;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class DataTypes {
-
-    public static BooleanType BOOLEAN_TYPE = new BooleanType();
-    public static ByteType BYTE_TYPE = new ByteType();
-    public static ShortType SHORT_TYPE = new ShortType();
-    public static IntType INT_TYPE = new IntType();
-    public static LongType LONG_TYPE = new LongType();
-    public static FloatType FLOAT_TYPE = new FloatType();
-    public static DoubleType DOUBLE_TYPE = new DoubleType();
-    public static BigIntegerType BIGINTEGER_TYPE = new BigIntegerType();
-    public static BigDecimalType BIGDECIMAL_TYPE = new BigDecimalType();
-    public static DateType DATE_TYPE = new DateType();
-    public static StringType STRING_TYPE = new StringType();
-    public static String ARRAY_TYPE_PREFIX = "array<";
-    static String ARRAY_TYPE_SUFFIX = ">";
-    public static String MAP_TYPE_PREFIX = "map<";
-    static String MAP_TYPE_SUFFIX = ">";
-
-    public static String arrayTypeName(String elemTypeName) {
-        assert elemTypeName != null;
-        return String.format("%s%s%s", ARRAY_TYPE_PREFIX, elemTypeName, ARRAY_TYPE_SUFFIX);
-    }
-
-    public static String arrayTypeName(IDataType elemType) {
-        return arrayTypeName(elemType.getName());
-    }
-
-    public static String mapTypeName(String keyTypeName, String valueTypeName) {
-        return String.format("%s%s,%s%s", MAP_TYPE_PREFIX, keyTypeName, valueTypeName, MAP_TYPE_SUFFIX);
-    }
-
-    public static String mapTypeName(IDataType keyType, IDataType valueType) {
-        assert keyType != null;
-        assert valueType != null;
-        return mapTypeName(keyType.getName(), valueType.getName());
-    }
-
-    public enum TypeCategory {
-        PRIMITIVE,
-        ENUM,
-        ARRAY,
-        MAP,
-        STRUCT,
-        TRAIT,
-        CLASS,
-        RELATIONSHIP
-    }
-
-    public static abstract class PrimitiveType<T> extends AbstractDataType<T> {
-        public PrimitiveType(String name, String description) {
-            super(name, description);
-        }
-
-        @Override
-        public TypeCategory getTypeCategory() {
-            return TypeCategory.PRIMITIVE;
-        }
-
-        public abstract T nullValue();
-
-        @Override
-        protected T convertNull(Multiplicity m) throws AtlasException {
-            if (!m.nullAllowed()) {
-                throw new ValueConversionException.NullConversionException(m);
-            }
-
-            return nullValue();
-        }
-
-        @Override
-        public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException {
-            if ( val != null ) {
-                digester.update(val.toString().getBytes(Charset.forName("UTF-8")));
-            }
-        }
-
-    }
-
-    public static class BooleanType extends PrimitiveType<Boolean> {
-
-        private static final String name = "boolean".intern();
-
-        private BooleanType() {
-            super(name, null);
-        }
-
-        @Override
-        public Boolean convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof Boolean) {
-                    return (Boolean) val;
-                } else if (val instanceof String) {
-                    return Boolean.parseBoolean((String) val);
-                } else if (val instanceof Number) {
-                    return ((Number) val).intValue() != 0;
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        public Boolean nullValue() {
-            return Boolean.FALSE;
-        }
-    }
-
-    public static class ByteType extends PrimitiveType<Byte> {
-
-        private static final String name = "byte".intern();
-
-        private ByteType() {
-            super(name, null);
-        }
-
-        @Override
-        public Byte convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof Byte) {
-                    return (Byte) val;
-                } else if (val instanceof String) {
-                    return Byte.parseByte((String) val);
-                } else if (val instanceof Number) {
-                    return ((Number) val).byteValue();
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        public Byte nullValue() {
-            return 0;
-        }
-
-        @Override
-        public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException {
-            if ( val != null ) {
-                digester.update((Byte) val);
-            }
-        }
-    }
-
-    public static class ShortType extends PrimitiveType<Short> {
-
-        private static final String name = "short".intern();
-
-        private ShortType() {
-            super(name, null);
-        }
-
-        @Override
-        public Short convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof Short) {
-                    return (Short) val;
-                } else if (val instanceof String) {
-                    return Short.parseShort((String) val);
-                } else if (val instanceof Number) {
-                    return ((Number) val).shortValue();
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        public Short nullValue() {
-            return 0;
-        }
-    }
-
-    public static class IntType extends PrimitiveType<Integer> {
-
-        private static final String name = "int".intern();
-
-        private IntType() {
-            super(name, null);
-        }
-
-        @Override
-        public Integer convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof Integer) {
-                    return (Integer) val;
-                } else if (val instanceof String) {
-                    return Integer.parseInt((String) val);
-                } else if (val instanceof Number) {
-                    return ((Number) val).intValue();
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        public Integer nullValue() {
-            return 0;
-        }
-    }
-
-    public static class LongType extends PrimitiveType<Long> {
-
-        private static final String name = "long".intern();
-
-        private LongType() {
-            super(name, null);
-        }
-
-        @Override
-        public Long convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof Long) {
-                    return (Long) val;
-                } else if (val instanceof String) {
-                    return Long.parseLong((String) val);
-                } else if (val instanceof Number) {
-                    return ((Number) val).longValue();
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        public Long nullValue() {
-            return 0L;
-        }
-    }
-
-    public static class FloatType extends PrimitiveType<Float> {
-
-        private static final String name = "float".intern();
-
-        private FloatType() {
-            super(name, null);
-        }
-
-        @Override
-        public Float convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof Float) {
-                    return (Float) val;
-                } else if (val instanceof String) {
-                    return Float.parseFloat((String) val);
-                } else if (val instanceof Number) {
-                    return ((Number) val).floatValue();
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        public Float nullValue() {
-            return 0.0f;
-        }
-    }
-
-    public static class DoubleType extends PrimitiveType<Double> {
-
-        private static final String name = "double".intern();
-
-        private DoubleType() {
-            super(name, null);
-        }
-
-        @Override
-        public Double convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof Double) {
-                    return (Double) val;
-                } else if (val instanceof String) {
-                    return Double.parseDouble((String) val);
-                } else if (val instanceof Number) {
-                    return ((Number) val).doubleValue();
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        public Double nullValue() {
-            return 0.0;
-        }
-    }
-
-    public static class BigIntegerType extends PrimitiveType<BigInteger> {
-
-        private static final String name = "biginteger".intern();
-
-        private BigIntegerType() {
-            super(name, null);
-        }
-
-        @Override
-        public BigInteger convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof BigInteger) {
-                    return (BigInteger) val;
-                } else if (val instanceof String) {
-                    try {
-                        return new BigInteger((String) val);
-                    } catch (NumberFormatException ne) {
-                        throw new ValueConversionException(this, val, ne);
-                    }
-                } else if (val instanceof Number) {
-                    return BigInteger.valueOf(((Number) val).longValue());
-                } else if (val instanceof BigDecimal) {
-                    return ((BigDecimal) val).toBigInteger();
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        public BigInteger nullValue() {
-            return null;
-        }
-    }
-
-    public static class BigDecimalType extends PrimitiveType<BigDecimal> {
-
-        private static final String name = "bigdecimal".intern();
-
-        private BigDecimalType() {
-            super(name, null);
-        }
-
-        @Override
-        public BigDecimal convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof BigDecimal) {
-                    return (BigDecimal) val;
-                } else if (val instanceof String) {
-                    try {
-                        return new BigDecimal((String) val);
-                    } catch (NumberFormatException ne) {
-                        throw new ValueConversionException(this, val, ne);
-                    }
-                } else if (val instanceof Number) {
-                    return new BigDecimal(((Number) val).doubleValue());
-                } else if (val instanceof BigInteger) {
-                    return new BigDecimal((BigInteger) val);
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        public BigDecimal nullValue() {
-            return null;
-        }
-    }
-
-    public static class DateType extends PrimitiveType<Date> {
-
-        private static final String name = "date".intern();
-
-        private DateType() {
-            super(name, null);
-        }
-
-        private static final DateTimeFormatter utcDateFormat = ISODateTimeFormat.dateTime();
-
-        @Override
-        public Date convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                if (val instanceof Date) {
-                    return (Date) val;
-                } else if (val instanceof String) {
-                    try {
-                        return utcDateFormat.parseDateTime((String)val).toDate();
-                    } catch (Exception ne) {
-                        throw new ValueConversionException(this, val, ne);
-                    }
-                } else if (val instanceof Number) {
-                    return new Date(((Number) val).longValue());
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            return convertNull(m);
-        }
-
-        @Override
-        public void output(Date val, Appendable buf, String prefix, Set<Date> inProcess) throws AtlasException {
-            TypeUtils.outputVal(val == null ? "<null>" : utcDateFormat.print(new DateTime(val).withZone(DateTimeZone.UTC)), buf,
-                    prefix);
-        }
-
-        public Date nullValue() {
-            return null;
-        }
-    }
-
-    public static class StringType extends PrimitiveType<String> {
-
-        private static final String name = "string".intern();
-
-        private StringType() {
-            super(name, null);
-        }
-
-        @Override
-        public String convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null && (!(val instanceof String) || StringUtils.isNotEmpty((CharSequence) val))) {
-                return val.toString();
-            }
-
-            if (m.nullAllowed() && val != null){
-                return val.toString();
-            }
-            return convertNull(m);
-        }
-
-        public String nullValue() {
-            return null;
-        }
-    }
-
-    public static class ArrayType extends AbstractDataType<ImmutableCollection<?>> {
-        private IDataType elemType;
-
-        public ArrayType(IDataType elemType) {
-            super(arrayTypeName(elemType), null);
-            this.elemType = elemType;
-        }
-
-        public IDataType getElemType() {
-            return elemType;
-        }
-
-        protected void setElemType(IDataType elemType) {
-            this.elemType = elemType;
-        }
-
-        @Override
-        public ImmutableCollection<?> convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                Iterator it = null;
-                if (val instanceof Collection) {
-                    it = ((Collection) val).iterator();
-                } else if (val instanceof Iterable) {
-                    it = ((Iterable) val).iterator();
-                } else if (val instanceof Iterator) {
-                    it = (Iterator) val;
-                }
-
-                if (it != null) {
-                    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));
-                    }
-                    return m.isUnique ? b.build().asList() : b.build();
-                } else {
-                    try {
-                        return ImmutableList.of(elemType.convert(val,
-                                TypeSystem.getInstance().allowNullsInCollections() ? Multiplicity.OPTIONAL :
-                                        Multiplicity.REQUIRED));
-                    } catch (Exception e) {
-                        throw new ValueConversionException(this, val, e);
-                    }
-                }
-            }
-            if (!m.nullAllowed()) {
-                throw new ValueConversionException.NullConversionException(m);
-            }
-            return null;
-        }
-
-        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();
-            for (Object elem : val) {
-                if (elem instanceof IReferenceableInstance) {
-                    Id oldId = ((IReferenceableInstance) elem).getId();
-                    Id newId = transientToNewIds.get(oldId);
-                    b.add(newId == null ? oldId : newId);
-                } else {
-                    b.add(elem);
-                }
-            }
-            return b.build();
-        }
-
-        @Override
-        public TypeCategory getTypeCategory() {
-            return TypeCategory.ARRAY;
-        }
-
-        @Override
-        public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException {
-            IDataType elemType = getElemType();
-            List vals = (List) val;
-            for (Object listElem : vals) {
-                elemType.updateSignatureHash(digester, listElem);
-            }
-        }
-    }
-
-    public static class MapType extends AbstractDataType<ImmutableMap<?, ?>> {
-
-        private IDataType keyType;
-        private IDataType valueType;
-
-        public MapType(IDataType keyType, IDataType valueType) {
-            super(mapTypeName(keyType, valueType), null);
-            this.keyType = keyType;
-            this.valueType = valueType;
-        }
-
-        public IDataType getKeyType() {
-            return keyType;
-        }
-
-        protected void setKeyType(IDataType keyType) {
-            this.keyType = keyType;
-        }
-
-        public IDataType getValueType() {
-            return valueType;
-        }
-
-        protected void setValueType(IDataType valueType) {
-            this.valueType = valueType;
-        }
-
-        @Override
-        public ImmutableMap<?, ?> convert(Object val, Multiplicity m) throws AtlasException {
-            if (val != null) {
-                Iterator<Map.Entry> it = null;
-                if (Map.class.isAssignableFrom(val.getClass())) {
-                    it = ((Map) val).entrySet().iterator();
-                    ImmutableMap.Builder b = ImmutableMap.builder();
-                    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(), Multiplicity.OPTIONAL));
-                    }
-                    return b.build();
-                } else {
-                    throw new ValueConversionException(this, val);
-                }
-            }
-            if (!m.nullAllowed()) {
-                throw new ValueConversionException.NullConversionException(m);
-            }
-            return null;
-        }
-
-        public ImmutableMap<?, ?> mapIds(ImmutableMap val, Multiplicity m, Map<Id, Id> transientToNewIds)
-        throws AtlasException {
-
-            if (val == null || (keyType.getTypeCategory() != TypeCategory.CLASS
-                    && valueType.getTypeCategory() != TypeCategory.CLASS)) {
-                return val;
-            }
-            ImmutableMap.Builder b = ImmutableMap.builder();
-            for (Map.Entry elem : (Iterable<Map.Entry>) val.entrySet()) {
-                Object oldKey = elem.getKey();
-                Object oldValue = elem.getValue();
-                Object newKey = oldKey;
-                Object newValue = oldValue;
-
-                if (oldKey instanceof IReferenceableInstance) {
-                    Id oldId = ((IReferenceableInstance) oldKey).getId();
-                    Id newId = transientToNewIds.get(oldId);
-                    newKey = newId == null ? oldId : newId;
-                }
-
-                if (oldValue instanceof IReferenceableInstance) {
-                    Id oldId = ((IReferenceableInstance) oldValue).getId();
-                    Id newId = transientToNewIds.get(oldId);
-                    newValue = newId == null ? oldId : newId;
-                }
-
-                b.put(newKey, newValue);
-            }
-            return b.build();
-        }
-
-        @Override
-        public TypeCategory getTypeCategory() {
-            return TypeCategory.MAP;
-        }
-
-        @Override
-        public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException {
-            IDataType keyType = getKeyType();
-            IDataType valueType = getValueType();
-            Map vals = (Map) val;
-            for (Object key : vals.keySet()) {
-                keyType.updateSignatureHash(digester, key);
-                valueType.updateSignatureHash(digester, vals.get(key));
-            }
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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
deleted file mode 100755
index 85e288e..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/DownCastFieldMapping.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.persistence.DownCastStructInstance;
-
-public class DownCastFieldMapping {
-
-    public final ImmutableMap<String, String> fieldNameMap;
-
-    protected DownCastFieldMapping(ImmutableMap<String, String> fieldNameMap) {
-        this.fieldNameMap = fieldNameMap;
-    }
-
-    public void set(DownCastStructInstance s, String attrName, Object val) throws AtlasException {
-
-        String mappedNm = fieldNameMap.get(attrName);
-        if (mappedNm == null) {
-            throw new ValueConversionException(s.getTypeName(), val, "Unknown field " + attrName);
-        }
-
-        s.backingInstance.set(mappedNm, val);
-    }
-
-    public Object get(DownCastStructInstance s, String attrName) throws AtlasException {
-
-        String mappedNm = fieldNameMap.get(attrName);
-        if (mappedNm == null) {
-            throw new ValueConversionException(
-                    String.format("Unknown field %s for Struct %s", attrName, s.getTypeName()));
-        }
-        return s.backingInstance.get(mappedNm);
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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
deleted file mode 100755
index 82e22ce..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumType.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import com.google.common.collect.ImmutableCollection;
-import com.google.common.collect.ImmutableMap;
-import org.apache.atlas.AtlasConstants;
-import org.apache.atlas.AtlasException;
-import scala.math.BigInt;
-
-import java.nio.charset.Charset;
-import java.security.MessageDigest;
-
-public class EnumType extends AbstractDataType<EnumValue> {
-
-    public final TypeSystem typeSystem;
-    public final ImmutableMap<String, EnumValue> valueMap;
-    public final ImmutableMap<Integer, EnumValue> ordinalMap;
-
-    protected EnumType(TypeSystem typeSystem, String name, EnumValue... values) {
-        this(typeSystem, name, null, values);
-    }
-
-    protected EnumType(TypeSystem typeSystem, String name, String description, EnumValue... values) {
-        this(typeSystem, name, description, AtlasConstants.DEFAULT_TYPE_VERSION, values);
-    }
-
-    protected EnumType(TypeSystem typeSystem, String name, String description, String version, EnumValue... values) {
-        super(name, description, version);
-        this.typeSystem = typeSystem;
-        ImmutableMap.Builder<String, EnumValue> b1 = new ImmutableMap.Builder();
-        ImmutableMap.Builder<Integer, EnumValue> b2 = new ImmutableMap.Builder();
-        for (EnumValue v : values) {
-            b1.put(v.value, v);
-            b2.put(v.ordinal, v);
-        }
-        valueMap = b1.build();
-        ordinalMap = b2.build();
-    }
-
-    @Override
-    public EnumValue convert(Object val, Multiplicity m) throws AtlasException {
-        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 = ordinalMap.get(val);
-            } else if (val instanceof String) {
-                e = valueMap.get(val);
-            } else if (val instanceof Number) {
-                e = ordinalMap.get(((Number) val).intValue());
-            }
-
-            if (e == null) {
-                throw new ValueConversionException(this, val);
-            }
-            return e;
-        }
-        return convertNull(m);
-    }
-
-    @Override
-    public DataTypes.TypeCategory getTypeCategory() {
-        return DataTypes.TypeCategory.ENUM;
-    }
-
-    @Override
-    public void validateUpdate(IDataType newType) throws TypeUpdateException {
-        super.validateUpdate(newType);
-
-        EnumType enumType = (EnumType) newType;
-        for (EnumValue enumValue : values()) {
-            //The old enum value should be part of new enum definition as well
-            if (!enumType.valueMap.containsKey(enumValue.value)) {
-                throw new TypeUpdateException("Value " + enumValue.value + " is missing in new type");
-            }
-
-            //The ordinal for old enum value can't change
-            EnumValue newEnumValue = enumType.valueMap.get(enumValue.value);
-            if (enumValue.ordinal != newEnumValue.ordinal) {
-                throw new TypeUpdateException(String.format("Ordinal mismatch %s(%s) != %s(%s)", enumValue.value,
-                        enumValue.ordinal, newEnumValue.value, newEnumValue.ordinal));
-            }
-        }
-    }
-
-    public void updateSignatureHash(MessageDigest digester, Object val) throws AtlasException {
-        if (val != null) {
-            digester.update(fromValue((String) val).toString().getBytes(Charset.forName("UTF-8")));
-        }
-    }
-
-    public EnumValue fromOrdinal(int o) {
-        return ordinalMap.get(o);
-    }
-
-    public EnumValue fromValue(String val) {
-        return valueMap.get(val.trim());
-    }
-
-    public ImmutableCollection<EnumValue> values() {
-        return valueMap.values();
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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
deleted file mode 100755
index 40cb132..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import org.apache.atlas.utils.ParamChecker;
-import org.apache.atlas.AtlasConstants;
-
-import java.util.Arrays;
-import java.util.Objects;
-
-public final class EnumTypeDefinition {
-
-    public final String name;
-    public final String description;
-    public final String version;
-    public final EnumValue[] enumValues;
-
-    public EnumTypeDefinition(String name, EnumValue... enumValues) {
-        this(name, null, AtlasConstants.DEFAULT_TYPE_VERSION, enumValues);
-    }
-
-    public EnumTypeDefinition(String name, String description, EnumValue... enumValues) {
-        this(name, description, AtlasConstants.DEFAULT_TYPE_VERSION, enumValues);
-    }
-
-    public EnumTypeDefinition(String name, String description, String version, EnumValue... enumValues) {
-        this.name = ParamChecker.notEmpty(name, "Enum type name");
-        this.description = description;
-        this.enumValues = ParamChecker.notNullElements(enumValues, "Enum values");
-        this.version = version;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        EnumTypeDefinition that = (EnumTypeDefinition) o;
-        return Objects.equals(name, that.name) &&
-                Objects.equals(description, that.description) &&
-                Objects.equals(version, that.version) &&
-                Arrays.equals(enumValues, that.enumValues);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(name, description, version, enumValues);
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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
deleted file mode 100755
index d75259b..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumValue.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import org.apache.atlas.utils.ParamChecker;
-
-public class EnumValue {
-
-    public final String value;
-    public final int ordinal;
-
-    public EnumValue(String value, int ordinal) {
-        this.value = ParamChecker.notEmpty(value, "Enum value");
-        this.ordinal = ordinal;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        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;
-        }
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = value.hashCode();
-        result = 31 * result + ordinal;
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        return value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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
deleted file mode 100755
index a2b3db2..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/FieldMapping.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.IReferenceableInstance;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.persistence.Id;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-public class FieldMapping {
-
-    public final Map<String, AttributeInfo> fields;
-    public final Map<String, Integer> fieldPos;
-    public final Map<String, Integer> fieldNullPos;
-    public final int numBools;
-    public final int numBytes;
-    public final int numShorts;
-    public final int numInts;
-    public final int numLongs;
-    public final int numFloats;
-    public final int numDoubles;
-    public final int numBigInts;
-    public final int numBigDecimals;
-    public final int numDates;
-    public final int numStrings;
-    public final int numArrays;
-    public final int numMaps;
-    public final int numStructs;
-    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) {
-        this.fields = fields;
-        this.fieldPos = fieldPos;
-        this.fieldNullPos = fieldNullPos;
-        this.numBools = numBools;
-        this.numBytes = numBytes;
-        this.numShorts = numShorts;
-        this.numInts = numInts;
-        this.numLongs = numLongs;
-        this.numFloats = numFloats;
-        this.numDoubles = numDoubles;
-        this.numBigInts = numBigInts;
-        this.numBigDecimals = numBigDecimals;
-        this.numDates = numDates;
-        this.numStrings = numStrings;
-        this.numArrays = numArrays;
-        this.numMaps = numMaps;
-        this.numStructs = numStructs;
-        this.numReferenceables = numReferenceables;
-    }
-
-    protected void outputFields(IStruct s, Appendable buf, String fieldPrefix, Set<? extends IStruct> inProcess) throws AtlasException {
-        for (Map.Entry<String, AttributeInfo> e : fields.entrySet()) {
-            String attrName = e.getKey();
-            AttributeInfo i = e.getValue();
-            Object aVal = s.get(attrName);
-            TypeUtils.outputVal(attrName + " : ", buf, fieldPrefix);
-            if (aVal != null && aVal instanceof Id) {
-                TypeUtils.outputVal(aVal.toString(), buf, "");
-            } else {
-                i.dataType().output(aVal, buf, fieldPrefix, inProcess);
-            }
-            TypeUtils.outputVal("\n", buf, "");
-        }
-    }
-
-    public void output(IStruct s, Appendable buf, String prefix, Set<IStruct> inProcess) throws AtlasException {
-        if (s == null) {
-            TypeUtils.outputVal("<null>\n", buf, "");
-            return;
-        }
-
-        if (inProcess == null) {
-            inProcess = new HashSet<>();
-        }
-        else if (inProcess.contains(s)) {
-            // Avoid infinite recursion when structs reference each other.
-            return;
-        }
-        inProcess.add(s);
-
-        try {
-            TypeUtils.outputVal("{", buf, prefix);
-
-            TypeUtils.outputVal("\n", buf, "");
-            String fieldPrefix = prefix + "\t";
-
-            outputFields(s, buf, fieldPrefix, inProcess);
-
-            TypeUtils.outputVal("}", buf, prefix);
-        }
-        finally {
-            inProcess.remove(s);
-        }
-    }
-
-    public void output(IReferenceableInstance s, Appendable buf, String prefix, Set<IReferenceableInstance> inProcess) throws AtlasException {
-        if (s == null) {
-            TypeUtils.outputVal("<null>\n", buf, "");
-            return;
-        }
-
-        if (inProcess == null) {
-            inProcess = new HashSet<>();
-        }
-        else if (inProcess.contains(s)) {
-            // Avoid infinite recursion when structs reference each other.
-            return;
-        }
-        inProcess.add(s);
-
-        try {
-            TypeUtils.outputVal("{", buf, prefix);
-
-            TypeUtils.outputVal("\n", buf, "");
-            String fieldPrefix = prefix + "\t";
-
-            TypeUtils.outputVal("id : ", buf, fieldPrefix);
-            TypeUtils.outputVal(s.getId().toString(), buf, "");
-            TypeUtils.outputVal("\n", buf, "");
-
-            outputFields(s, buf, fieldPrefix, inProcess);
-
-            TypeSystem ts = TypeSystem.getInstance();
-
-            for (String sT : s.getTraits()) {
-                TraitType tt = ts.getDataType(TraitType.class, sT);
-                TypeUtils.outputVal(sT + " : ", buf, fieldPrefix);
-                tt.output(s.getTrait(sT), buf, fieldPrefix, null);
-            }
-
-            TypeUtils.outputVal("}", buf, prefix);
-        }
-        finally {
-            inProcess.remove(s);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/atlas/blob/0877e47c/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
deleted file mode 100755
index ac7f442..0000000
--- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalType.java
+++ /dev/null
@@ -1,545 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.atlas.typesystem.types;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.UnmodifiableIterator;
-
-import org.apache.atlas.AtlasConstants;
-import org.apache.atlas.AtlasException;
-import org.apache.atlas.typesystem.IStruct;
-import org.apache.atlas.typesystem.persistence.DownCastStructInstance;
-import org.apache.atlas.typesystem.types.TypeUtils.Pair;
-
-import java.io.IOException;
-import java.util.*;
-
-/**
- * Represents a Type that can have SuperTypes. An Instance of the HierarchicalType can be
- * downcast to a SuperType.
- * @param <ST> the Type of the SuperType. TraitTypes have TraitTypes as SuperTypes, ClassTypes
- *            have ClassTypes
- *            as SuperTypes.
- * @param <T> the class of the Instance of this DataType.
- */
-public abstract class HierarchicalType<ST extends HierarchicalType, T> extends AbstractDataType<T> {
-
-    public final TypeSystem typeSystem;
-    public final Class<ST> superTypeClass;
-    public final FieldMapping fieldMapping;
-    public final int numFields;
-    public final ImmutableSet<String> superTypes;
-    public final ImmutableList<AttributeInfo> immediateAttrs;
-    public final ImmutableMap<String, String> attributeNameToType;
-    protected ImmutableMap<String, List<Path>> superTypePaths;
-    protected ImmutableMap<String, Path> pathNameToPathMap;
-
-    HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, String name, ImmutableSet<String> superTypes,
-        int numFields) {
-        this(typeSystem, superTypeClass, name, null, superTypes, numFields);
-    }
-
-    /**
-     * Used when creating a Type, to support recursive Structs.
-     */
-    HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, String name, String description, ImmutableSet<String> superTypes,
-            int numFields) {
-        this( typeSystem, superTypeClass, name, description, AtlasConstants.DEFAULT_TYPE_VERSION, superTypes, numFields);
-    }
-
-    HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, String name, String description, String version, ImmutableSet<String> superTypes,
-                     int numFields) {
-        super(name, description, version);
-        this.typeSystem = typeSystem;
-        this.superTypeClass = superTypeClass;
-        this.fieldMapping = null;
-        this.numFields = numFields;
-        this.superTypes = superTypes;
-        this.immediateAttrs = ImmutableList.of();
-        this.attributeNameToType = null;
-    }
-
-    HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, String name, ImmutableSet<String> superTypes,
-        AttributeInfo... fields) throws AtlasException {
-        this(typeSystem, superTypeClass, name, null, superTypes, fields);
-    }
-    HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, String name, String description, ImmutableSet<String> superTypes,
-            AttributeInfo... fields) throws AtlasException {
-        this(typeSystem, superTypeClass, name, description, AtlasConstants.DEFAULT_TYPE_VERSION, superTypes, fields);
-    }
-
-    HierarchicalType(TypeSystem typeSystem, Class<ST> superTypeClass, String name, String description, String version, ImmutableSet<String> superTypes,
-                     AttributeInfo... fields) throws AtlasException {
-        super(name, description, version);
-        this.typeSystem = typeSystem;
-        this.superTypeClass = superTypeClass;
-        Pair<FieldMapping, ImmutableMap<String, String>> p = constructFieldMapping(superTypes, fields);
-        this.fieldMapping = p.left;
-        this.attributeNameToType = p.right;
-        this.numFields = this.fieldMapping.fields.size();
-        this.superTypes = superTypes == null ? ImmutableSet.<String>of() : superTypes;
-        this.immediateAttrs = ImmutableList.copyOf(fields);
-    }
-
-    public FieldMapping fieldMapping() {
-        return fieldMapping;
-    }
-
-    /**
-     * Given type must be a SubType of this type.
-     * @param typeName
-     * @throws AtlasException
-     */
-    public boolean isSubType(String typeName) throws AtlasException {
-        HierarchicalType cType = typeSystem.getDataType(HierarchicalType.class, typeName);
-        return (cType == this || cType.superTypePaths.containsKey(getName()));
-    }
-
-    /**
-     * Validate that current definition can be updated with the new definition
-     * @param newType
-     * @return true if the current definition can be updated with the new definition, else false
-     */
-    @Override
-    public void validateUpdate(IDataType newType) throws TypeUpdateException {
-        super.validateUpdate(newType);
-
-        HierarchicalType newHierarchicalType = (HierarchicalType) newType;
-
-        //validate on supertypes
-
-        if ((newHierarchicalType.superTypes.size() != superTypes.size())
-                || !newHierarchicalType.superTypes.containsAll(superTypes)) {
-            throw new TypeUpdateException(newType, "New type cannot modify superTypes");
-        }
-
-        //validate on fields
-        try {
-            TypeUtils.validateUpdate(fieldMapping, newHierarchicalType.fieldMapping);
-        } catch (TypeUpdateException e) {
-            throw new TypeUpdateException(newType, e);
-        }
-    }
-
-    protected void setupSuperTypesGraph() throws AtlasException {
-        setupSuperTypesGraph(superTypes);
-    }
-
-    private void setupSuperTypesGraph(ImmutableSet<String> superTypes) throws AtlasException {
-        Map<String, List<Path>> superTypePaths = new HashMap<>();
-        Map<String, Path> pathNameToPathMap = new HashMap<>();
-        Queue<Path> queue = new LinkedList<>();
-        queue.add(new Node(getName()));
-        while (!queue.isEmpty()) {
-            Path currentPath = queue.poll();
-
-            ST superType = Objects.equals(currentPath.typeName, getName()) ? (ST) this :
-                    typeSystem.getDataType(superTypeClass, currentPath.typeName);
-
-            pathNameToPathMap.put(currentPath.pathName, currentPath);
-            if (superType != this) {
-                List<Path> typePaths = superTypePaths.get(superType.getName());
-                if (typePaths == null) {
-                    typePaths = new ArrayList<>();
-                    superTypePaths.put(superType.getName(), typePaths);
-                }
-                typePaths.add(currentPath);
-            }
-
-            ImmutableSet<String> sTs = superType == this ? superTypes : superType.superTypes;
-
-            if (sTs != null) {
-                for (String sT : sTs) {
-                    queue.add(new Path(sT, currentPath));
-                }
-            }
-        }
-
-        this.superTypePaths = ImmutableMap.copyOf(superTypePaths);
-        this.pathNameToPathMap = ImmutableMap.copyOf(pathNameToPathMap);
-
-    }
-
-    protected Pair<FieldMapping, ImmutableMap<String, String>> constructFieldMapping(ImmutableSet<String> superTypes,
-            AttributeInfo... fields) throws AtlasException {
-
-        Map<String, AttributeInfo> fieldsMap = new LinkedHashMap();
-        Map<String, Integer> fieldPos = new HashMap();
-        Map<String, Integer> fieldNullPos = new HashMap();
-        Map<String, String> attributeNameToType = new HashMap<>();
-
-        int numBools = 0;
-        int numBytes = 0;
-        int numShorts = 0;
-        int numInts = 0;
-        int numLongs = 0;
-        int numFloats = 0;
-        int numDoubles = 0;
-        int numBigInts = 0;
-        int numBigDecimals = 0;
-        int numDates = 0;
-        int numStrings = 0;
-        int numArrays = 0;
-        int numMaps = 0;
-        int numStructs = 0;
-        int numReferenceables = 0;
-
-        setupSuperTypesGraph(superTypes);
-
-        Iterator<Path> pathItr = pathIterator();
-        while (pathItr.hasNext()) {
-            Path currentPath = pathItr.next();
-
-            ST superType = Objects.equals(currentPath.typeName, getName()) ? (ST) this :
-                    typeSystem.getDataType(superTypeClass, currentPath.typeName);
-
-            ImmutableList<AttributeInfo> superTypeFields =
-                    superType == this ? ImmutableList.copyOf(fields) : superType.immediateAttrs;
-
-            Set<String> immediateFields = new HashSet<>();
-
-            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));
-                    }
-                    immediateFields.add(i.name);
-                }
-
-                String attrName = i.name;
-                if (fieldsMap.containsKey(attrName)) {
-                    attrName = currentPath.addOverrideAttr(attrName);
-                }
-                attributeNameToType.put(attrName, superType.getName());
-
-                fieldsMap.put(attrName, i);
-                fieldNullPos.put(attrName, fieldNullPos.size());
-                if (i.dataType() == DataTypes.BOOLEAN_TYPE) {
-                    fieldPos.put(attrName, numBools);
-                    numBools++;
-                } else if (i.dataType() == DataTypes.BYTE_TYPE) {
-                    fieldPos.put(attrName, numBytes);
-                    numBytes++;
-                } else if (i.dataType() == DataTypes.SHORT_TYPE) {
-                    fieldPos.put(attrName, numShorts);
-                    numShorts++;
-                } else if (i.dataType() == DataTypes.INT_TYPE) {
-                    fieldPos.put(attrName, numInts);
-                    numInts++;
-                } else if (i.dataType() == DataTypes.LONG_TYPE) {
-                    fieldPos.put(attrName, numLongs);
-                    numLongs++;
-                } else if (i.dataType() == DataTypes.FLOAT_TYPE) {
-                    fieldPos.put(attrName, numFloats);
-                    numFloats++;
-                } else if (i.dataType() == DataTypes.DOUBLE_TYPE) {
-                    fieldPos.put(attrName, numDoubles);
-                    numDoubles++;
-                } else if (i.dataType() == DataTypes.BIGINTEGER_TYPE) {
-                    fieldPos.put(attrName, numBigInts);
-                    numBigInts++;
-                } else if (i.dataType() == DataTypes.BIGDECIMAL_TYPE) {
-                    fieldPos.put(attrName, numBigDecimals);
-                    numBigDecimals++;
-                } else if (i.dataType() == DataTypes.DATE_TYPE) {
-                    fieldPos.put(attrName, numDates);
-                    numDates++;
-                } else if (i.dataType() == DataTypes.STRING_TYPE) {
-                    fieldPos.put(attrName, numStrings);
-                    numStrings++;
-                } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.ENUM) {
-                    fieldPos.put(i.name, numInts);
-                    numInts++;
-                } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.ARRAY) {
-                    fieldPos.put(attrName, numArrays);
-                    numArrays++;
-                } 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) {
-                    fieldPos.put(attrName, numStructs);
-                    numStructs++;
-                } else if (i.dataType().getTypeCategory() == DataTypes.TypeCategory.CLASS) {
-                    fieldPos.put(attrName, numReferenceables);
-                    numReferenceables++;
-                } else {
-                    throw new AtlasException(String.format("Unknown datatype %s", i.dataType()));
-                }
-            }
-        }
-
-        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);
-
-        return new Pair(fm, ImmutableMap.copyOf(attributeNameToType));
-    }
-
-    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()));
-        }
-
-        if (s != null) {
-            if (!Objects.equals(s.getTypeName(), getName())) {
-                throw new AtlasException(
-                        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()));
-            }
-
-            ST superType = typeSystem.getDataType(superTypeClass, superTypeName);
-            Map<String, String> downCastMap = superType.constructDowncastFieldMap(this, pathToSuper.get(0));
-            return new DownCastStructInstance(superTypeName, new DownCastFieldMapping(ImmutableMap.copyOf(downCastMap)),
-                    s);
-        }
-
-        return null;
-    }
-
-    public ST getDefinedType(String attrName) throws AtlasException {
-        if (!attributeNameToType.containsKey(attrName)) {
-            throw new AtlasException(String.format("Unknown attribute %s in type %s", attrName, getName()));
-        }
-        return typeSystem.getDataType(superTypeClass, attributeNameToType.get(attrName));
-    }
-
-    public String getDefinedTypeName(String attrName) throws AtlasException {
-        return getDefinedType(attrName).getName();
-    }
-
-    public String getQualifiedName(String attrName) throws AtlasException {
-        String attrTypeName = getDefinedTypeName(attrName);
-        return attrName.contains(".") ? attrName : String.format("%s.%s", attrTypeName, attrName);
-    }
-
-    protected Map<String, String> constructDowncastFieldMap(ST subType, Path pathToSubType) {
-
-        String pathToSubTypeName = pathToSubType.pathAfterThis;
-        /*
-         * the downcastMap;
-         */
-        Map<String, String> dCMap = new HashMap<>();
-        Iterator<Path> itr = pathIterator();
-        while (itr.hasNext()) {
-            Path p = itr.next();
-            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;
-                    if (mappedInThisType == null) {
-                        dCMap.put(e.getKey(), e.getValue());
-                    } else {
-                        dCMap.put(mappedInThisType, e.getValue());
-                    }
-                }
-            }
-        }
-        return dCMap;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder buf = new StringBuilder();
-        try {
-            output(buf, new HashSet<String>());
-        }
-        catch (AtlasException e) {
-            throw new RuntimeException(e);
-        }
-        return buf.toString();
-    }
-
-    @Override
-    public void output(Appendable buf, Set<String> typesInProcess) throws AtlasException {
-
-        if (typesInProcess == null) {
-            typesInProcess = new HashSet<>();
-        }
-        else if (typesInProcess.contains(name)) {
-            // Avoid infinite recursion on bi-directional reference attributes.
-            try {
-                buf.append(name);
-            } catch (IOException e) {
-                throw new AtlasException(e);
-            }
-            return;
-        }
-
-        typesInProcess.add(name);
-        try {
-            buf.append(getClass().getSimpleName()).append('{');
-            buf.append("name=").append(name);
-            buf.append(", description=").append(description);
-            buf.append(", superTypes=").append(superTypes.toString());
-            buf.append(", immediateAttrs=[");
-            UnmodifiableIterator<AttributeInfo> it = immediateAttrs.iterator();
-            while (it.hasNext()) {
-                AttributeInfo attrInfo = it.next();
-                attrInfo.output(buf, typesInProcess);
-                if (it.hasNext()) {
-                    buf.append(", ");
-                }
-                else {
-                    buf.append(']');
-                }
-            }
-            buf.append("}");
-        }
-        catch(IOException e) {
-            throw new AtlasException(e);
-        }
-        finally {
-            typesInProcess.remove(name);
-        }
-    }
-
-    public Set<String> getAllSuperTypeNames() {
-        return superTypePaths.keySet();
-    }
-
-    public Iterator<Path> pathIterator() {
-        return new PathItr();
-    }
-
-    static class Path {
-        public final String typeName;
-        public final String pathName;
-        public final String pathAfterThis;
-        private final Path subTypePath;
-        /*
-         * name mapping for attributes hidden by a SubType.
-         */ Map<String, String> hiddenAttributeMap;
-
-        Path(String typeName, Path childPath) throws AtlasException {
-            this.typeName = typeName;
-            this.subTypePath = childPath;
-            if (childPath.contains(typeName)) {
-                throw new CyclicTypeDefinition(this);
-            }
-            pathName = String.format("%s.%s", typeName, childPath.pathName);
-            pathAfterThis = childPath.pathName;
-        }
-
-        Path(String typeName) {
-            assert getClass() == Node.class;
-            this.typeName = typeName;
-            this.subTypePath = null;
-            pathName = typeName;
-            pathAfterThis = null;
-        }
-
-        public boolean contains(String typeName) {
-            return this.typeName.equals(typeName) || (subTypePath != null && subTypePath.contains(typeName));
-        }
-
-        public String pathString(String nodeSep) {
-
-            StringBuilder b = new StringBuilder();
-            Path p = this;
-
-            while (p != null) {
-                b.append(p.typeName);
-                p = p.subTypePath;
-                if (p != null) {
-                    b.append(nodeSep);
-                }
-            }
-            return b.toString();
-        }
-
-        String addOverrideAttr(String name) {
-            hiddenAttributeMap = hiddenAttributeMap == null ? new HashMap<String, String>() : hiddenAttributeMap;
-            String oName = pathName + "." + name;
-            hiddenAttributeMap.put(name, oName);
-            return oName;
-        }
-    }
-
-    static class Node extends Path {
-        Node(String typeName) {
-            super(typeName);
-        }
-    }
-
-    static class CyclicTypeDefinition extends AtlasException {
-
-        CyclicTypeDefinition(Path p) {
-            super(String.format("Cycle in Type Definition %s", p.pathString(" -> ")));
-        }
-    }
-
-    class PathItr implements Iterator<Path> {
-
-        Queue<Path> pathQueue;
-
-        PathItr() {
-            pathQueue = new LinkedList<>();
-            pathQueue.add(pathNameToPathMap.get(getName()));
-        }
-
-        @Override
-        public boolean hasNext() {
-            return !pathQueue.isEmpty();
-        }
-
-        @Override
-        public Path next() {
-            Path p = pathQueue.poll();
-
-            if(p != null) {
-                ST t = null;
-                try {
-                    t = typeSystem.getDataType(superTypeClass, p.typeName);
-                } catch (AtlasException me) {
-                    throw new RuntimeException(me);
-                }
-                if (t.superTypes != null) {
-                    for (String sT : (ImmutableSet<String>) t.superTypes) {
-                        String nm = sT + "." + p.pathName;
-                        pathQueue.add(pathNameToPathMap.get(nm));
-                    }
-                }
-            }
-            return p;
-        }
-
-        @Override
-        public void remove() {
-            throw new UnsupportedOperationException();
-        }
-    }
-}