コード例 #1
0
 static Object[] getElements(RawObject collection) {
   Object value = null;
   while (value == null && collection != null) {
     Map<String, Object> values = collection.getValues();
     if (values != null) {
       value = values.get("elements");
       if (value == null) {
         collection = collection.getSuper();
       }
     }
   }
   if (value == null || !(value instanceof RawObject)) {
     throw new IllegalStateException(
         "Collection proxy for a secondary key field must " + "contain a field named 'elements'");
   }
   RawObject rawObj = (RawObject) value;
   Format format = (Format) rawObj.getType();
   if (!format.isArray() || format.getComponentType().getId() != Format.ID_OBJECT) {
     throw new IllegalStateException("Collection proxy 'elements' field must by an Object array");
   }
   return rawObj.getElements();
 }