use of weborb.reader.ReferenceCache in project Android-SDK by Backendless.
the class BackendlessFileFactory method createObject.
public Object createObject(IAdaptingType argument) {
if (argument instanceof NamedObject)
argument = ((NamedObject) argument).getTypedObject();
if (argument.getClass().getName().equals("weborb.reader.NullType"))
return null;
ReferenceCache refCache = ReferenceCache.getInstance();
if (refCache.hasObject(argument, BackendlessFile.class)) {
return refCache.getObject(argument, BackendlessFile.class);
} else {
if (argument instanceof StringType) {
StringType stringType = (StringType) argument;
BackendlessFile file;
if (Backendless.isAndroid())
file = new BackendlessFileAndroid(stringType.getValue());
else
file = new BackendlessFile(stringType.getValue());
refCache.addObject(argument, BackendlessFile.class, file);
return file;
} else
throw new RuntimeException("unknown type");
}
}
use of weborb.reader.ReferenceCache in project Android-SDK by Backendless.
the class BackendlessUserFactory method createObject.
@Override
public Object createObject(IAdaptingType iAdaptingType) {
if (iAdaptingType instanceof NamedObject)
iAdaptingType = ((NamedObject) iAdaptingType).getTypedObject();
if (iAdaptingType.getClass().getName().equals("weborb.reader.NullType"))
return null;
ReferenceCache refCache = ReferenceCache.getInstance();
BackendlessUser backendlessUser;
if (refCache.hasObject(iAdaptingType, BackendlessUser.class)) {
return refCache.getObject(iAdaptingType, BackendlessUser.class);
} else {
backendlessUser = new BackendlessUser();
refCache.addObject(iAdaptingType, BackendlessUser.class, backendlessUser);
}
HashMap props;
try {
props = (HashMap) iAdaptingType.adapt(HashMap.class);
} catch (Throwable t) {
props = new HashMap();
}
backendlessUser.setProperties(props);
return backendlessUser;
}
Aggregations