@Override public PropertyKey make() { Preconditions.checkArgument(dataType != null, "Need to specify a datatype"); Preconditions.checkArgument( tx.validDataType(dataType), "Not a supported data type: %s", dataType); Preconditions.checkArgument( !dataType.isPrimitive(), "Primitive types are not supported. Use the corresponding object type, e.g. Integer.class instead of int.class [%s]", dataType); Preconditions.checkArgument( !dataType.isInterface(), "Datatype must be a class and not an interface: %s", dataType); Preconditions.checkArgument( dataType.isArray() || !Modifier.isAbstract(dataType.getModifiers()), "Datatype cannot be an abstract class: %s", dataType); TypeDefinitionMap definition = makeDefinition(); definition.setValue(DATATYPE, dataType); return tx.makePropertyKey(getName(), definition); }
public TitanGraphIndex getExternalIndex(Class<? extends Element> clazz, String backingIndex) { String prefix; if (Vertex.class.isAssignableFrom(clazz)) prefix = "v"; else if (Edge.class.isAssignableFrom(clazz)) prefix = "e"; else if (TitanVertexProperty.class.isAssignableFrom(clazz)) prefix = "p"; else throw new AssertionError(clazz.toString()); String indexName = prefix + backingIndex; TitanGraphIndex index = mgmt.getGraphIndex(indexName); if (index == null) { index = mgmt.buildIndex(indexName, clazz).buildMixedIndex(backingIndex); } return index; }