static { EnumType[] var0 = values(); int var1 = var0.length; for (int var2 = 0; var2 < var1; var2++) { EnumType var3 = var0[var2]; METADATA[var3.getMetadata()] = var3; } }
static { EnumType[] stateArray = values(); int var1 = stateArray.length; for (int i = 0; i < var1; ++i) { EnumType metas = stateArray[i]; META_LOOKUP[metas.getMetadata()] = metas; } }
private boolean ValidateEnum(String value, EnumType e) { String name; String v; name = e.getEnumName(); v = String.valueOf(e.getEnumValue()); if (value.equals(name) || value.equals(v)) return true; else return false; }
/** returns a list of block with the same ID, but different meta (eg: wood returns 4 block) */ @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { EnumType[] aenumtype = EnumType.values(); int i = aenumtype.length; for (int j = 0; j < i; ++j) { EnumType enumtype = aenumtype[j]; list.add(new ItemStack(itemIn, 1, enumtype.getMetadata())); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((type == null) ? 0 : type.hashCode()); return result; }
private static ValueType newValueType( Map<Type, ValueType> typeMap, Type type, Class declaringClass, Class compositeType) { ValueType valueType = null; if (CollectionType.isCollection(type)) { if (type instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType) type; Type collectionType = pt.getActualTypeArguments()[0]; if (collectionType instanceof TypeVariable) { TypeVariable collectionTypeVariable = (TypeVariable) collectionType; collectionType = Classes.resolveTypeVariable(collectionTypeVariable, declaringClass, compositeType); } ValueType collectedType = newValueType(typeMap, collectionType, declaringClass, compositeType); valueType = new CollectionType(nameOf(type), collectedType); } else { valueType = new CollectionType( nameOf(type), newValueType(typeMap, Object.class, declaringClass, compositeType)); } } else if (ValueCompositeType.isValueComposite(type)) { if (typeMap != null) { valueType = typeMap.get(type); } if (valueType == null) { Class valueTypeClass = Classes.getRawClass(type); List<PropertyType> types = new ArrayList<PropertyType>(); valueType = new ValueCompositeType(nameOf(valueTypeClass), types); if (typeMap == null) { typeMap = new HashMap<Type, ValueType>(); } typeMap.put(type, valueType); addProperties(typeMap, valueTypeClass, compositeType, types); Collections.sort(types); // Sort by property name } } else if (EnumType.isEnum(type)) { valueType = new EnumType(nameOf(type)); } else if (StringType.isString(type)) { valueType = new StringType(); } else if (NumberType.isNumber(type)) { valueType = new NumberType(nameOf(type)); } else if (BooleanType.isBoolean(type)) { valueType = new BooleanType(); } else if (DateType.isDate(type)) { valueType = new DateType(); } else if (EntityReferenceType.isEntityReference(type)) { valueType = new EntityReferenceType(nameOf(type)); } else { // TODO: shouldn't we check that the type is a Serializable? valueType = new SerializableType(nameOf(type)); } return valueType; }
public static PrimitiveType valueOf(String typeName) { return new PrimitiveType(EnumType.valueOf(typeName)); }
@Override public String getName() { return type.toString(); }
@Override public String toString() { return type.toString(); }
static { for (EnumType i : values()) { META_LOOKUP[i.getMetadata()] = i; } }
public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(VARIANT, EnumType.byMetadata(meta)); }
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { for (EnumType i : EnumType.values()) { list.add(new ItemStack(itemIn, 1, i.getMetadata())); } }
@Override public String getSpecialName(ItemStack stack) { return EnumType.byMetadata(stack.getItemDamage()).getUnlocalizedName(); }
/* * collect some information needed for code gen process of the graph * type model data structures * */ protected void collectGraphTypeModelInfo() { /* overall number of node and edge types */ n_node_types = getIDs(true).length; n_edge_types = getIDs(false).length; /* overall number of enum types */ n_enum_types = enumMap.size(); /* overall number of node and edge attributes declared in the grg file */ n_node_attrs = nodeAttrMap.size(); n_edge_attrs = edgeAttrMap.size(); /* get the inheritance information of the node and edge types */ node_is_a_matrix = getIsAMatrix(true); edge_is_a_matrix = getIsAMatrix(false); /* count the number of attrs a node type has */ n_attr_of_node_type = new int[n_node_types]; // fill that array with 0 for (int i = 0; i < n_node_types; i++) n_attr_of_node_type[i] = 0; // count number of attributes for (Entity attr : nodeAttrMap.keySet()) { assert attr.hasOwner() : "Thought, that the Entity represented a node class attr and that\n" + "thus there had to be a type that owned the entity, but there was non."; Type node_type = attr.getOwner(); // get the id of the node type, where the attr is declared in int node_type_id = nodeTypeMap.get(node_type).intValue(); assert node_type_id < n_node_types : "Tried to use a node-type-id as array index, " + "but the id exceeded the number of node types"; // increment the number of attributes for the declaring type... n_attr_of_node_type[node_type_id]++; // ...but the attr is also contained in all sub types, i.e. increment there too for (int nt_id = 0; nt_id < n_node_types; nt_id++) if (node_is_a_matrix[nt_id][node_type_id] > 0) n_attr_of_node_type[nt_id]++; } /* count the number of attrs an edge type has */ n_attr_of_edge_type = new int[n_edge_types]; // fill that array with 0 for (int i = 0; i < n_edge_types; i++) n_attr_of_edge_type[i] = 0; // count number of attributes for (Entity attr : edgeAttrMap.keySet()) { assert attr.hasOwner() : "Thought, that the Entity represented an edge class attr and that\n" + "thus there had to be a type that owned the entity, but there was non."; Type edge_type = attr.getOwner(); // get the id of the edge type, where the attr is declared in int edge_type_id = edgeTypeMap.get(edge_type).intValue(); assert edge_type_id < n_edge_types : "Tried to use an edge-type-id as array index," + "but the id exceeded the number of edge types"; // increment the number of attributes for the declaring type... n_attr_of_edge_type[edge_type_id]++; // ...but the attr is also contained in all sub types, i.e. increment there too for (int et_id = 0; et_id < n_edge_types; et_id++) if (edge_is_a_matrix[et_id][edge_type_id] > 0) n_attr_of_edge_type[et_id]++; } /* collect all needed information about node attributes */ node_attr_info = new AttrTypeDescriptor[n_node_attrs]; for (Entity attr : nodeAttrMap.keySet()) { assert attr.hasOwner() : "Thought, that the Entity represented an node attr and that thus\n" + "there had to be a type that owned the entity, but there was non."; NodeType node_type = (NodeType) attr.getOwner(); int node_type_id = nodeTypeMap.get(node_type).intValue(); int attr_id = nodeAttrMap.get(attr).intValue(); node_attr_info[attr_id] = new AttrTypeDescriptor(); // set the attr id node_attr_info[attr_id].attr_id = attr_id; // get the attributes name node_attr_info[attr_id].name = attr.getIdent().toString(); // get the owners type id node_attr_info[attr_id].decl_owner_type_id = node_type_id; // get the attributes kind if (attr.getType() instanceof IntType) node_attr_info[attr_id].kind = AttrTypeDescriptor.INTEGER; else if (attr.getType() instanceof BooleanType) node_attr_info[attr_id].kind = AttrTypeDescriptor.BOOLEAN; else if (attr.getType() instanceof StringType) node_attr_info[attr_id].kind = AttrTypeDescriptor.STRING; else if (attr.getType() instanceof EnumType) { node_attr_info[attr_id].kind = AttrTypeDescriptor.ENUM; node_attr_info[attr_id].enum_id = enumMap.get(attr.getType()).intValue(); } else { System.err.println( "Key element of AttrNodeMap has a type, which is " + "neither one of 'int', 'boolean', 'string' nor an enumeration type."); System.exit(0); } } /* collect all needed information about edge attributes */ edge_attr_info = new AttrTypeDescriptor[n_edge_attrs]; for (Entity attr : edgeAttrMap.keySet()) { assert attr.hasOwner() : "Thought, that the Entity represented an edge attr and that thus\n" + "there had to be a type that owned the entity, but there was non."; EdgeType edge_type = (EdgeType) attr.getOwner(); int edge_type_id = edgeTypeMap.get(edge_type).intValue(); int attr_id = edgeAttrMap.get(attr).intValue(); edge_attr_info[attr_id] = new AttrTypeDescriptor(); // set the attr id edge_attr_info[attr_id].attr_id = attr_id; // get the attributes name edge_attr_info[attr_id].name = attr.getIdent().toString(); // get the owners type id edge_attr_info[attr_id].decl_owner_type_id = edge_type_id; // get the attributes kind if (attr.getType() instanceof IntType) edge_attr_info[attr_id].kind = AttrTypeDescriptor.INTEGER; else if (attr.getType() instanceof BooleanType) edge_attr_info[attr_id].kind = AttrTypeDescriptor.BOOLEAN; else if (attr.getType() instanceof StringType) edge_attr_info[attr_id].kind = AttrTypeDescriptor.STRING; else if (attr.getType() instanceof EnumType) { edge_attr_info[attr_id].kind = AttrTypeDescriptor.ENUM; edge_attr_info[attr_id].enum_id = enumMap.get(attr.getType()).intValue(); } else { System.err.println( "Key element of AttrEdgeMap has a type, which is " + "neither one of 'int', 'boolean', 'string' nor an enumeration type."); System.exit(0); } } /* compute the attr layout of the node types given in the grg file */ node_attr_index = new int[n_node_types][n_node_attrs]; // for all node types... for (int nt = 0; nt < n_node_types; nt++) { // the index the current attr will get in the current node layout, if it's a member int attr_index = 0; // ...and all node attribute IDs... for (int attr_id = 0; attr_id < n_node_attrs; attr_id++) { // ...check whether the attr is owned by the node type or one of its supertype int owner = node_attr_info[attr_id].decl_owner_type_id; if (owner == nt || node_is_a_matrix[nt][owner] > 0) // setup the attrs index in the layout of the current node type node_attr_index[nt][attr_id] = attr_index++; else // -1 means that the current attr is not a member of the current node type node_attr_index[nt][attr_id] = -1; } } /* compute the attr layout of the edge types given in the grg file */ edge_attr_index = new int[n_edge_types][n_edge_attrs]; // for all edge types... for (int et = 0; et < n_edge_types; et++) { // the index the current attr will get in the current edge layout, if it's a member int attr_index = 0; // ...and all edge attribute IDs... for (int attr_id = 0; attr_id < n_edge_attrs; attr_id++) { // ...check whether the attr is owned by the edge type or one of its supertype int owner = edge_attr_info[attr_id].decl_owner_type_id; if (owner == et || edge_is_a_matrix[et][owner] > 0) // setup the attrs index in the layout of the current node type edge_attr_index[et][attr_id] = attr_index++; else // -1 means that the current attr is not a member of the current node type edge_attr_index[et][attr_id] = -1; } } // collect the information about the enumeration types enum_type_descriptors = new EnumDescriptor[n_enum_types]; for (int et = 0; et < n_enum_types; et++) enum_type_descriptors[et] = new EnumDescriptor(); for (EnumType enum_type : enumMap.keySet()) { // store the info about the current enum type in an array... // ...type id int enum_type_id = enumMap.get(enum_type).intValue(); enum_type_descriptors[enum_type_id].type_id = enum_type_id; // ...the identifier used in the grg-file to declare thar enum type enum_type_descriptors[enum_type_id].name = enum_type.getIdent().toString(); // ..the items in this enumeration type for (EnumItem item : enum_type.getItems()) { enum_type_descriptors[enum_type_id].items.add(item); } // ...the number of items enum_type_descriptors[enum_type_id].n_items = enum_type_descriptors[enum_type_id].items.size(); } }