From: <aki...@us...> - 2013-05-24 20:01:30
|
Revision: 9214 http://sourceforge.net/p/gridarta/code/9214 Author: akirschbaum Date: 2013-05-24 20:01:25 +0000 (Fri, 24 May 2013) Log Message: ----------- Update comment. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java Modified: trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java 2013-05-24 19:56:48 UTC (rev 9213) +++ trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java 2013-05-24 20:01:25 UTC (rev 9214) @@ -45,10 +45,7 @@ private ArchetypeType fallbackArchetypeType; /** - * Lists with all {@link ArchetypeType ArchetypeTypes}. Contains all but the - * default archetype type. - * @todo verify whether the default ArchetypeType really is not included in - * this list. + * Lists with all defined {@link ArchetypeType ArchetypeTypes}. */ @NotNull private final List<ArchetypeType> archetypeTypeList = new ArrayList<ArchetypeType>(); // All but the default ArchetypeType This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-05-24 20:28:36
|
Revision: 9219 http://sourceforge.net/p/gridarta/code/9219 Author: akirschbaum Date: 2013-05-24 20:28:32 +0000 (Fri, 24 May 2013) Log Message: ----------- Update comments. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java Modified: trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java 2013-05-24 20:26:58 UTC (rev 9218) +++ trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java 2013-05-24 20:28:32 UTC (rev 9219) @@ -45,10 +45,11 @@ private ArchetypeType fallbackArchetypeType = new ArchetypeType("", 0, "", true, null, false, null, null, 2, new ArchetypeAttributes(), new ArchetypeAttributesDefinition()); /** - * Lists with all defined {@link ArchetypeType ArchetypeTypes}. + * Lists with all defined {@link ArchetypeType ArchetypeTypes}. The ordering + * is the same as in the "types.xml" file. */ @NotNull - private final List<ArchetypeType> archetypeTypeList = new ArrayList<ArchetypeType>(); // All but the default ArchetypeType + private final List<ArchetypeType> archetypeTypeList = new ArrayList<ArchetypeType>(); /** * Table with {@link List} objects for lists (value) accessible by name This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-05-24 20:30:39
|
Revision: 9220 http://sourceforge.net/p/gridarta/code/9220 Author: akirschbaum Date: 2013-05-24 20:30:30 +0000 (Fri, 24 May 2013) Log Message: ----------- Accelerate archetype type lookups. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java Modified: trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java 2013-05-24 20:28:32 UTC (rev 9219) +++ trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java 2013-05-24 20:30:30 UTC (rev 9220) @@ -174,12 +174,7 @@ */ @Nullable public Iterable<ArchetypeAttribute> getArchetypeType(@NotNull final String typeName) { - for (final ArchetypeType archetypeType : archetypeTypeList) { - if (archetypeType.getTypeName().equals(typeName)) { - return archetypeType; - } - } - return null; + return archetypeTypeNames.get(typeName); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-05-24 20:34:02
|
Revision: 9221 http://sourceforge.net/p/gridarta/code/9221 Author: akirschbaum Date: 2013-05-24 20:33:54 +0000 (Fri, 24 May 2013) Log Message: ----------- Reorder code. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java Modified: trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java 2013-05-24 20:30:30 UTC (rev 9220) +++ trunk/model/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeSet.java 2013-05-24 20:33:54 UTC (rev 9221) @@ -52,6 +52,13 @@ private final List<ArchetypeType> archetypeTypeList = new ArrayList<ArchetypeType>(); /** + * Table with type archetype type name as keys ({@link String}), and {@link + * ArchetypeType} object as values (<code>ArchetypeType</code>). + */ + @NotNull + private final Map<String, ArchetypeType> archetypeTypeNames = new HashMap<String, ArchetypeType>(); + + /** * Table with {@link List} objects for lists (value) accessible by name * (key). */ @@ -66,58 +73,27 @@ private final Map<String, AttributeBitmask> bitmaskTable = new HashMap<String, AttributeBitmask>(); /** - * Table with type archetype type name as keys ({@link String}), and {@link - * ArchetypeType} object as values (<code>ArchetypeType</code>). - */ - @NotNull - private final Map<String, ArchetypeType> archetypeTypeNames = new HashMap<String, ArchetypeType>(); - - /** - * Returns a list type definition. - * @param listName the list name - * @return the list type definition or <code>null</code> if the list does - * not exist - */ - @Nullable - public ArchetypeTypeList getList(@NotNull final String listName) { - return listTable.get(listName); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public Iterator<ArchetypeType> iterator() { - return Collections.unmodifiableList(archetypeTypeList).iterator(); - } - - /** - * Returns the index of an {@link ArchetypeType} instance. + * Adds an {@link ArchetypeType} instance. * @param archetypeType the archetype type instance - * @return the index */ - public int getArchetypeTypeIndex(@NotNull final ArchetypeType archetypeType) { - return archetypeTypeList.indexOf(archetypeType); + public void add(@NotNull final ArchetypeType archetypeType) { + archetypeTypeList.add(archetypeType); + final String typeName = archetypeType.getTypeName(); + archetypeTypeNames.put(typeName, archetypeType); + if (typeName.equals("Misc")) { + fallbackArchetypeType = archetypeType; + } } /** - * Returns the number of ArchetypeTypes in the list. The default type is not - * counted. - * @return the number of archetype types in the list + * Returns an {@link ArchetypeType} by type name. + * @param typeName the type name to look up + * @return the archetype type instance or <code>null</code> if the type name + * does not exist */ - public int getLength() { - return archetypeTypeList.size(); - } - - /** - * Returns a bitmask type by name. - * @param bitmaskName the bitmask name to look up - * @return the bitmask type or <code>null</code> if the name does not exist - */ @Nullable - public AttributeBitmask getBitmask(@NotNull final String bitmaskName) { - return bitmaskTable.get(bitmaskName); + public Iterable<ArchetypeAttribute> getArchetypeType(@NotNull final String typeName) { + return archetypeTypeNames.get(typeName); } /** @@ -157,40 +133,43 @@ } /** - * Returns a description of this type. - * @param baseObject the base object to describe - * @return the description + * {@inheritDoc} */ @NotNull - public String getDisplayName(@NotNull final BaseObject<?, ?, ?, ?> baseObject) { - return getArchetypeType(baseObject).getDisplayName(baseObject); + @Override + public Iterator<ArchetypeType> iterator() { + return Collections.unmodifiableList(archetypeTypeList).iterator(); } /** - * Returns an {@link ArchetypeType} by type name. - * @param typeName the type name to look up - * @return the archetype type instance or <code>null</code> if the type name - * does not exist + * Returns the index of an {@link ArchetypeType} instance. + * @param archetypeType the archetype type instance + * @return the index */ - @Nullable - public Iterable<ArchetypeAttribute> getArchetypeType(@NotNull final String typeName) { - return archetypeTypeNames.get(typeName); + public int getArchetypeTypeIndex(@NotNull final ArchetypeType archetypeType) { + return archetypeTypeList.indexOf(archetypeType); } /** - * Adds an {@link ArchetypeType} instance. - * @param archetypeType the archetype type instance + * Returns the number of ArchetypeTypes in the list. The default type is not + * counted. + * @return the number of archetype types in the list */ - public void add(@NotNull final ArchetypeType archetypeType) { - archetypeTypeList.add(archetypeType); - final String typeName = archetypeType.getTypeName(); - archetypeTypeNames.put(typeName, archetypeType); - if (typeName.equals("Misc")) { - fallbackArchetypeType = archetypeType; - } + public int getLength() { + return archetypeTypeList.size(); } /** + * Returns whether a given {@link ArchetypeType} is the fallback archetype + * type used for game objects not matching any defined archetype type. + * @param archetypeType the archetype type to check + * @return whether the given archetype type is the fallback archetype type + */ + public boolean isFallbackArchetypeType(@NotNull final ArchetypeType archetypeType) { + return archetypeType == fallbackArchetypeType; + } + + /** * Adds a list definition. * @param attribute the attribute name * @param list the list definition @@ -200,6 +179,17 @@ } /** + * Returns a list type definition. + * @param listName the list name + * @return the list type definition or <code>null</code> if the list does + * not exist + */ + @Nullable + public ArchetypeTypeList getList(@NotNull final String listName) { + return listTable.get(listName); + } + + /** * Adds a bitmask definition. * @param attribute the attribute name * @param attributeBitmask the list definition @@ -209,6 +199,26 @@ } /** + * Returns a bitmask type by name. + * @param bitmaskName the bitmask name to look up + * @return the bitmask type or <code>null</code> if the name does not exist + */ + @Nullable + public AttributeBitmask getBitmask(@NotNull final String bitmaskName) { + return bitmaskTable.get(bitmaskName); + } + + /** + * Returns a description of this type. + * @param baseObject the base object to describe + * @return the description + */ + @NotNull + public String getDisplayName(@NotNull final BaseObject<?, ?, ?, ?> baseObject) { + return getArchetypeType(baseObject).getDisplayName(baseObject); + } + + /** * {@inheritDoc} */ @NotNull @@ -236,14 +246,4 @@ sb.append('\n'); } - /** - * Returns whether a given {@link ArchetypeType} is the fallback archetype - * type used for game objects not matching any defined archetype type. - * @param archetypeType the archetype type to check - * @return whether the given archetype type is the fallback archetype type - */ - public boolean isFallbackArchetypeType(@NotNull final ArchetypeType archetypeType) { - return archetypeType == fallbackArchetypeType; - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |