Changeset 7610
- Timestamp:
- Feb 27, 2019, 2:18:43 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/src/docbook/appendix/incompatible.xml
r7609 r7610 80 80 are several similar changes in the <classname docapi="net.sf.basedb.core">ItemContext</classname> 81 81 class as well as in <classname docapi="net.sf.basedb.core">SessionControl</classname>, 82 <classname docapi="net.sf.basedb.core">Annotation</classname>, 83 <classname docapi="net.sf.basedb.core">AnnotationType</classname> 82 84 <classname docapi="net.sf.basedb.clients.web.formatter">FormatterFactory</classname>, 83 85 <classname docapi="net.sf.basedb.core">ParameterValues</classname> and several other -
trunk/src/clients/web/net/sf/basedb/clients/web/ExperimentExplorer.java
r7516 r7610 891 891 } 892 892 893 @SuppressWarnings("unchecked")894 893 private void initReporterCache(DbControl dc) 895 894 { … … 901 900 StaticCache staticCache = Application.getStaticCache(); 902 901 String cacheKey = "explorer/" + (id % 1000) + "/poslist-" + id + ".ser"; 903 List<Integer> posList = (List<Integer>)staticCache.load(cacheKey, 100);902 List<Integer> posList = staticCache.load(cacheKey, 100); 904 903 if (posList == null) 905 904 { -
trunk/src/core/net/sf/basedb/core/Annotation.java
r7461 r7610 593 593 @throws BaseException If there is an error 594 594 */ 595 public List<?> getValues()595 public <T> List<T> getValues() 596 596 throws BaseException 597 597 { 598 598 if (getSource() == Source.INHERITED) return Collections.emptyList(); 599 List< ?> values = Values.getItemValues(getDbControl(), getData().getValues().getValues());599 List<T> values = Values.getItemValues(getDbControl(), getData().getValues().getValues()); 600 600 return Collections.unmodifiableList(values); 601 601 } … … 613 613 @since 2.9 614 614 */ 615 public List<?> getValues(Unit unit) 615 @SuppressWarnings("unchecked") 616 public <T> List<T> getValues(Unit unit) 616 617 throws BaseException 617 618 { 618 619 if (getSource() == Source.INHERITED) return Collections.emptyList(); 619 List< ?> values = Values.getItemValues(getDbControl(), getData().getValues().getValues());620 List<T> values = Values.getItemValues(getDbControl(), getData().getValues().getValues()); 620 621 UnitConverter converter = getUnitConverter(unit); 621 622 if (converter != null) 622 623 { 623 List< Object> convertedValues = new ArrayList<Object>(values.size());624 List<T> convertedValues = new ArrayList<>(values.size()); 624 625 Type valueType = getValueType(); 625 for ( Objectvalue : values)626 for (T value : values) 626 627 { 627 628 if (value instanceof Number) 628 629 { 629 value = valueType.convertNumber(converter.convertToSpecificUnit(((Number)value).doubleValue()));630 value = (T)valueType.convertNumber(converter.convertToSpecificUnit(((Number)value).doubleValue())); 630 631 } 631 632 convertedValues.add(value); -
trunk/src/core/net/sf/basedb/core/AnnotationSet.java
r7381 r7610 475 475 getData().setItemId(itemId); 476 476 } 477 item = (Annotatable)getItemType().getById(dc, itemId);477 item = getItemType().getById(dc, itemId); 478 478 } 479 479 else if (dc != null) 480 480 { 481 item = (Annotatable)getItemType().getById(dc, item.getId());481 item = getItemType().getById(dc, item.getId()); 482 482 } 483 483 return item; -
trunk/src/core/net/sf/basedb/core/AnnotationType.java
r7381 r7610 1206 1206 @throws BaseException If there is an error 1207 1207 */ 1208 public List<?> getValues()1208 public <T> List<T> getValues() 1209 1209 throws BaseException 1210 1210 { -
trunk/src/core/net/sf/basedb/core/DbControl.java
r7605 r7610 974 974 { 975 975 constructorParams = new Object[1]; 976 c = (Constructor<? extends I>)itemType.getConstructor();976 c = itemType.getConstructor(); 977 977 } 978 978 constructorParams[0] = data; -
trunk/src/core/net/sf/basedb/core/Item.java
r7511 r7610 827 827 @throws BaseException If there is another error 828 828 */ 829 public BasicItem getById(DbControl dc, int id) 829 @SuppressWarnings("unchecked") 830 public <T extends BasicItem> T getById(DbControl dc, int id) 830 831 throws ItemNotFoundException, PermissionDeniedException, BaseException 831 832 { … … 838 839 try 839 840 { 840 return ( BasicItem)getById.invoke(null, dc, id);841 return (T)getById.invoke(null, dc, id); 841 842 } 842 843 catch (Throwable ex) … … 876 877 */ 877 878 @SuppressWarnings("unchecked") 878 public ItemQuery<? extends BasicItem> getQuery()879 public <T extends BasicItem> ItemQuery<T> getQuery() 879 880 { 880 881 if (getQuery == null) … … 886 887 try 887 888 { 888 return (ItemQuery< ? extends BasicItem>)getQuery.invoke(null);889 return (ItemQuery<T>)getQuery.invoke(null); 889 890 } 890 891 catch (Throwable ex) … … 915 916 @see DbControl#getItem(Class, BasicData, Object[]) 916 917 */ 917 Constructor<? extends BasicItem> getConstructor() 918 { 919 return constructor; 918 @SuppressWarnings("unchecked") 919 <T extends BasicItem> Constructor<T> getConstructor() 920 { 921 return (Constructor<T>)constructor; 920 922 } 921 923 -
trunk/src/core/net/sf/basedb/core/ItemContext.java
r7605 r7610 1170 1170 } 1171 1171 1172 @SuppressWarnings("unchecked")1173 1172 private <T extends BasicItem> List<T> loadRecent(DbControl dc, Item itemType, String key) 1174 1173 { … … 1179 1178 try 1180 1179 { 1181 recent.add( (T)itemType.getById(dc, Integer.parseInt(id)));1180 recent.add(itemType.getById(dc, Integer.parseInt(id))); 1182 1181 } 1183 1182 catch (Throwable t) -
trunk/src/core/net/sf/basedb/core/ItemList.java
r7599 r7610 676 676 @see Item#getQuery() 677 677 */ 678 @SuppressWarnings("unchecked")679 678 public ItemQuery<? extends Listable> getAllItems() 680 679 throws BaseException 681 680 { 682 return (ItemQuery<? extends Listable>)getMemberType().getQuery();681 return getMemberType().getQuery(); 683 682 } 684 683 -
trunk/src/core/net/sf/basedb/core/Values.java
r5384 r7610 61 61 @throws BaseException If there is another error 62 62 */ 63 static Object getItemValue(DbControl dc, Object value) 63 @SuppressWarnings("unchecked") 64 static <T> T getItemValue(DbControl dc, Object value) 64 65 throws PermissionDeniedException, BaseException 65 66 { … … 79 80 } 80 81 } 81 return value;82 return (T)value; 82 83 } 83 84 … … 86 87 @see #getItemValue(DbControl, Object) 87 88 */ 88 static List<Object> getItemValues(DbControl dc, List<?> dataValues)89 static <T> List<T> getItemValues(DbControl dc, List<?> dataValues) 89 90 throws PermissionDeniedException, ItemNotFoundException, BaseException 90 91 { … … 92 93 try 93 94 { 94 List< Object> itemValues = new ArrayList<Object>(dataValues.size());95 List<T> itemValues = new ArrayList<>(dataValues.size()); 95 96 for (int i = 0; i < dataValues.size(); i++) 96 97 { … … 114 115 @param value The value to convert 115 116 */ 116 static Object getDataValue(Object value) 117 @SuppressWarnings("unchecked") 118 static <T> T getDataValue(Object value) 117 119 { 118 120 if (value instanceof Date) … … 124 126 value = ((BasicItem)value).getData(); 125 127 } 126 return value;128 return (T)value; 127 129 } 128 130 … … 131 133 @see #getDataValue(Object) 132 134 */ 133 static List<Object> getDataValues(List<?> itemValues)135 static <T> List<T> getDataValues(List<?> itemValues) 134 136 { 135 137 if (itemValues == null) return null; 136 List< Object> dataValues = new ArrayList<Object>(itemValues.size());138 List<T> dataValues = new ArrayList<>(itemValues.size()); 137 139 for (int i = 0; i < itemValues.size(); i++) 138 140 { -
trunk/src/core/net/sf/basedb/core/snapshot/AnnotationSetSnapshot.java
r7250 r7610 147 147 public Annotatable getItem(DbControl dc) 148 148 { 149 return (Annotatable)itemType.getById(dc, itemId);149 return itemType.getById(dc, itemId); 150 150 } 151 151 -
trunk/src/core/net/sf/basedb/core/snapshot/AnnotationSnapshot.java
r7250 r7610 467 467 @return A list with the values or null 468 468 */ 469 public List<? extends Serializable> getThisValues() 470 { 471 return values; 469 @SuppressWarnings("unchecked") 470 public <T extends Serializable> List<T> getThisValues() 471 { 472 return (List<T>)values; 472 473 } 473 474 … … 478 479 @since 3.6 479 480 */ 480 public List<? extends Serializable> getActualValues() 481 { 482 return inheritedFrom != null && values == null ? inheritedFrom.values : values; 481 @SuppressWarnings("unchecked") 482 public <T extends Serializable> List<T> getActualValues() 483 { 484 return (List<T>)(inheritedFrom != null && values == null ? inheritedFrom.values : values); 483 485 } 484 486 … … 501 503 */ 502 504 @Deprecated 503 public List<? extends Serializable> getValues(UnitConverter converter, Type valueType)505 public <T extends Serializable> List<T> getValues(UnitConverter converter, Type valueType) 504 506 { 505 507 return getActualValues(converter, valueType); … … 522 524 @since 3.6 523 525 */ 524 public List<? extends Serializable> getActualValues(UnitConverter converter, Type valueType) 525 { 526 List<? extends Serializable> vals = getActualValues(); 526 @SuppressWarnings("unchecked") 527 public <T extends Serializable> List<T> getActualValues(UnitConverter converter, Type valueType) 528 { 529 List<T> vals = getActualValues(); 527 530 if (converter == null) return vals; 528 List< Serializable> convertedValues = new ArrayList<Serializable>(vals.size());529 for ( Serializablevalue : vals)531 List<T> convertedValues = new ArrayList<>(vals.size()); 532 for (T value : vals) 530 533 { 531 534 if (value instanceof Number) 532 535 { 533 value = valueType.convertNumber(converter.convertToSpecificUnit(((Number)value).doubleValue()));536 value = (T)valueType.convertNumber(converter.convertToSpecificUnit(((Number)value).doubleValue())); 534 537 } 535 538 convertedValues.add(value); … … 597 600 public Annotatable getItem(DbControl dc) 598 601 { 599 return getItemId() == 0 ? null : (Annotatable)getItemType().getById(dc, getItemId());602 return getItemId() == 0 ? null : getItemType().getById(dc, getItemId()); 600 603 } 601 604 … … 607 610 public Annotatable getThisItem(DbControl dc) 608 611 { 609 return itemId == 0 ? null : (Annotatable)itemType.getById(dc, itemId);612 return itemId == 0 ? null : itemType.getById(dc, itemId); 610 613 } 611 614 -
trunk/src/core/net/sf/basedb/core/snapshot/SnapshotManager.java
r7299 r7610 171 171 StaticCache cache = Application.getStaticCache(); 172 172 String cacheKey = getCacheKey(annotationSetId); 173 snapshot = (AnnotationSetSnapshot)cache.load(cacheKey, 1000);173 snapshot = cache.load(cacheKey, 1000); 174 174 if (snapshot == null) 175 175 { -
trunk/src/core/net/sf/basedb/util/OwnableUtil.java
r4587 r7610 60 60 if (id != null) 61 61 { 62 Ownable item = (Ownable)itemType.getById(dc, id);62 Ownable item = itemType.getById(dc, id); 63 63 if (item.hasPermission(Permission.SET_OWNER)) 64 64 { … … 88 88 if (ownedItem != null) 89 89 { 90 Ownable item = (Ownable)ownedItem.getType().getById(dc, ownedItem.getId());90 Ownable item = ownedItem.getType().getById(dc, ownedItem.getId()); 91 91 if (item.hasPermission(Permission.SET_OWNER)) 92 92 { -
trunk/src/core/net/sf/basedb/util/RemovableUtil.java
r5020 r7610 61 61 if (id != null) 62 62 { 63 Removable item = (Removable)itemType.getById(dc, id);63 Removable item = itemType.getById(dc, id); 64 64 if (item.isRemoved() != removed) 65 65 { … … 100 100 if (id != null) 101 101 { 102 Removable item = (Removable)itemType.getById(dc, id);102 Removable item = itemType.getById(dc, id); 103 103 numHandled = removeDependingItems(dc, item, removed); 104 104 if ((item instanceof Directory || item instanceof File) && !removed) -
trunk/src/core/net/sf/basedb/util/ShareableUtil.java
r4889 r7610 60 60 if (id != null) 61 61 { 62 SharedItem item = (SharedItem)itemType.getById(dc, id);62 SharedItem item = itemType.getById(dc, id); 63 63 if (item.hasPermission(Permission.SET_PERMISSION)) 64 64 { -
trunk/src/core/net/sf/basedb/util/StaticCache.java
r7352 r7610 407 407 exists or if a read lock couldn't be aquired 408 408 */ 409 public Objectload(String key, int timeout)409 public <T> T load(String key, int timeout) 410 410 { 411 411 return load(key, null, timeout); 412 412 } 413 413 414 public Object load(String key, ClassLoader loader, int timeout) 414 @SuppressWarnings("unchecked") 415 public <T> T load(String key, ClassLoader loader, int timeout) 415 416 { 416 417 if (disabled) return null; … … 469 470 } 470 471 } 471 return object;472 return (T)object; 472 473 473 474 } -
trunk/src/core/net/sf/basedb/util/annotations/RunnableInheritAnnotationsManager.java
r6909 r7610 118 118 ThreadSignalHandler.checkInterrupted(); 119 119 // Reload item in current transaction 120 item = (Annotatable)item.getType().getById(dc, item.getId());120 item = item.getType().getById(dc, item.getId()); 121 121 122 122 itemName = item instanceof Nameable ? ((Nameable)item).getName() : item.toString(); -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/FallbackIdMethod.java
r7101 r7610 139 139 load the item. 140 140 */ 141 @SuppressWarnings("unchecked")142 141 @Override 143 142 public <I extends BasicItem> List<I> find(DbControl dc, ItemQuery<I> query, String identifier) … … 151 150 try 152 151 { 153 I item = (I)query.getItemType().getById(dc, id);152 I item = query.getItemType().getById(dc, id); 154 153 items = Collections.singletonList(item); 155 154 } -
trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/InternalIdMethod.java
r4513 r7610 102 102 used except to find the type of item to load. 103 103 */ 104 @SuppressWarnings("unchecked")105 104 @Override 106 105 public <I extends BasicItem> List<I> find(DbControl dc, ItemQuery<I> query, String identifier) … … 112 111 try 113 112 { 114 I item = (I)query.getItemType().getById(dc, id);113 I item = query.getItemType().getById(dc, id); 115 114 items.add(item); 116 115 } -
trunk/src/test/net/sf/basedb/test/roles/UserTest.java
r6958 r7610 717 717 for (Annotatable parent : parents) 718 718 { 719 parent = (Annotatable)parent.getType().getById(dc, parent.getId());719 parent = parent.getType().getById(dc, parent.getId()); 720 720 if (parent.isAnnotated()) 721 721 { -
trunk/www/admin/annotationtypes/edit_annotationtype.jsp
r7604 r7610 644 644 <% 645 645 String values = annotationType == null ? "" : 646 Values.getString( (List<Date>)annotationType.getValues(), "\n", true, dateFormatter);646 Values.getString(annotationType.getValues(), "\n", true, dateFormatter); 647 647 %> 648 648 <textarea class="text" rows="10" name="values" id="values"
Note: See TracChangeset
for help on using the changeset viewer.