本文整理汇总了Java中com.google.web.bindery.autobean.shared.AutoBean类的典型用法代码示例。如果您正苦于以下问题:Java AutoBean类的具体用法?Java AutoBean怎么用?Java AutoBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AutoBean类属于com.google.web.bindery.autobean.shared包,在下文中一共展示了AutoBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSystemTabItem
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
private TabBarItemComponent createSystemTabItem(EnumSystemTabItemType itemType) {
TabBarItem tabBarItem = null;
TabBarItemComponent component = null;
AutoBean<TabBarItem> TabBarItemBean = AutoBeanService.getInstance().getFactory().tabBarItem();
tabBarItem = TabBarItemBean.as();
switch (itemType) {
case PREVIOUS:
tabBarItem.setName("<");
break;
case NEXT:
tabBarItem.setName(">");
break;
}
component = new TabBarItemComponent(tabBarItem, itemType);
// Add handlers as not created by usual mechanism
if(BrowserUtils.isMobile) {
systemTabHandlers.add(component.addDomHandler(this, TouchStartEvent.getType()));
systemTabHandlers.add(component.addDomHandler(this, TouchEndEvent.getType()));
} else {
systemTabHandlers.add(component.addDomHandler(this, MouseDownEvent.getType()));
systemTabHandlers.add(component.addDomHandler(this, MouseUpEvent.getType()));
systemTabHandlers.add(component.addDomHandler(this, MouseOutEvent.getType()));
}
systemTabHandlers.add(component.addHandler(component, TapEvent.getType()));
return component;
}
示例2: testGetMethod
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/** Tests that a top-level method is parsed as expected. */
public void testGetMethod() {
RpcApiMethod get = service.getMethods().get("moderator.get");
assertEquals(ImmutableList.of("https://www.googleapis.com/auth/scopename"), get.getScopes());
assertEquals(ImmutableList.<String>of(), get.getParameterOrder());
Schema param = get.getParameters().get("param");
assertFalse(param.isRequired());
assertNull(param.getPattern());
@SuppressWarnings("unchecked")
AutoBean<RpcApiService> serviceBean = EasyMock.createMock(AutoBean.class);
EasyMock.expect(serviceBean.as()).andReturn(service).anyTimes();
EasyMock.replay(serviceBean);
Schema returnsSchema = ApiServiceWrapper.responseSchema(serviceBean, get);
assertEquals(Type.OBJECT, returnsSchema.getType());
Schema status = returnsSchema.getProperties().get("status");
assertEquals(Type.STRING, status.getType());
}
示例3: makePayload
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
@Override
public String makePayload() {
final RequestData data =
AbstractRequestContext.this.state.invocations.get(0).getRequestData();
final AutoBean<JsonRpcRequest> bean = MessageFactoryHolder.FACTORY.jsonRpcRequest();
final JsonRpcRequest request = bean.as();
request.setVersion("2.0");
request.setApiVersion(data.getApiVersion());
request.setId(payloadId++);
final Map<String, Splittable> params = new HashMap<>();
for (final Map.Entry<String, Object> entry : data.getNamedParameters().entrySet()) {
final Object obj = entry.getValue();
final Splittable value = this.encode(obj);
params.put(entry.getKey(), value);
}
if (data.getRequestResource() != null) {
params.put("resource", this.encode(data.getRequestResource()));
}
request.setParams(params);
request.setMethod(data.getOperation());
return AutoBeanCodex.encode(bean).getPayload();
}
示例4: editProxy
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/**
* Take ownership of a proxy instance and make it editable.
*/
public <T extends BaseProxy> T editProxy(final T object) {
AutoBean<T> bean = this.checkStreamsNotCrossed(object);
this.checkLocked();
@SuppressWarnings("unchecked")
final AutoBean<T> previouslySeen =
(AutoBean<T>) this.state.editedProxies.get(BaseProxyCategory.stableId(bean));
if (previouslySeen != null && !previouslySeen.isFrozen()) {
/*
* If we've seen the object before, it might be because it was passed in as a method argument.
* This does not guarantee its mutability, so check that here before returning the cached
* object.
*/
return previouslySeen.as();
}
// Create editable copies
final AutoBean<T> parent = bean;
bean = this.cloneBeanAndCollections(bean);
bean.setTag(Constants.PARENT_OBJECT, parent);
return bean.as();
}
示例5: getSerializedProxyId
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/**
* EntityCodex support.
*/
@Override
public Splittable getSerializedProxyId(final SimpleProxyId<?> stableId) {
final AutoBean<IdMessage> bean = MessageFactoryHolder.FACTORY.id();
final IdMessage ref = bean.as();
ref.setServerId(stableId.getServerId());
ref.setTypeToken(this.getRequestFactory().getTypeToken(stableId.getProxyClass()));
if (stableId.isSynthetic()) {
ref.setStrength(Strength.SYNTHETIC);
ref.setSyntheticId(stableId.getSyntheticId());
} else if (stableId.isEphemeral()) {
ref.setStrength(Strength.EPHEMERAL);
ref.setClientId(stableId.getClientId());
}
return AutoBeanCodex.encode(bean);
}
示例6: createProxy
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/**
* Creates a new proxy with an assigned ID.
*
* @param clazz The proxy type
* @param id The id to be assigned to the new proxy
* @param useAppendedContexts if {@code true} use the AutoBeanFactory types associated with any
* contexts that have been passed into {@link #append(RequestContext)}. If {@code false},
* this method will only create proxy types reachable from the implemented RequestContext
* interface.
* @throws IllegalArgumentException if the requested proxy type cannot be created
*/
protected <T extends BaseProxy> AutoBean<T> createProxy(final Class<T> clazz,
final SimpleProxyId<T> id, final boolean useAppendedContexts) {
AutoBean<T> created = null;
if (useAppendedContexts) {
for (final AbstractRequestContext ctx : this.state.appendedContexts) {
created = ctx.getAutoBeanFactory().create(clazz);
if (created != null) {
break;
}
}
} else {
created = this.getAutoBeanFactory().create(clazz);
}
if (created != null) {
created.setTag(STABLE_ID, id);
return created;
}
throw new IllegalArgumentException("Unknown proxy type " + clazz.getName());
}
示例7: checkStreamsNotCrossed
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/**
* This method checks that a proxy object is either immutable, or already edited by this context.
*/
private <T> AutoBean<T> checkStreamsNotCrossed(final T object) {
final AutoBean<T> bean = AutoBeanUtils.getAutoBean(object);
if (bean == null) {
// Unexpected; some kind of foreign implementation?
throw new IllegalArgumentException(object.getClass().getName());
}
final State otherState = bean.getTag(REQUEST_CONTEXT_STATE);
if (!bean.isFrozen() && otherState != this.state) {
/*
* This means something is way off in the weeds. If a bean is editable, it's supposed to be
* associated with a RequestContext.
*/
assert otherState != null : "Unfrozen bean with null RequestContext";
/*
* Already editing the object in another context or it would have been in the editing map.
*/
throw new IllegalArgumentException(
"Attempting to edit an EntityProxy" + " previously edited by another RequestContext");
}
return bean;
}
示例8: toJsonString
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
public String toJsonString(AutoBean<?> obj) {
String result = "";
if (obj != null) {
result = AutoBeanCodex.encode(obj).getPayload();
}
return result;
}
示例9: fromJsonString
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
public <T> AutoBean<T> fromJsonString(Class<T> clazz, String json) {
AutoBean<T> bean = null;
if (json != null && !json.equals("")) {
bean = AutoBeanCodex.decode(factory, clazz, json);
}
return bean;
}
示例10: getData
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public AutoBean<?> getData(String dataSource, List<DataValuePairContainer> data) {
BindingMap map = BindingMap.getBindingMap(dataSource);
AutoBean<?> bean = null;
if (map != null) {
String obj = WebConsole.getConsoleUnit().getLocalDataService().getObjectString(map.getDataSource());
if (obj == null || obj.equals("")) {
// Look in supplied data
String dataString = null;
if (data != null) {
for (DataValuePairContainer dvpC : data) {
if (dvpC != null) {
DataValuePair dvp = dvpC.getDataValuePair();
if (dvp.getName().equalsIgnoreCase(dataSource)) {
obj = dvp.getValue();
break;
}
}
}
}
}
if (obj != null && !obj.equals("")) {
bean = AutoBeanService.getInstance().fromJsonString(map.getClazz(), obj);
} else {
bean = AutoBeanService.getInstance().getFactory().create(map.getClazz());
}
}
return bean;
}
示例11: showWelcomeMessage
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/**
* Determines if the welcome message should be shown by checking: -
* URL parameter
* Javascript variable
* Local storage
* @return
*/
public static boolean showWelcomeMessage() {
boolean showWelcome = true;
String param = Window.Location.getParameter("showWelcome");
if (param == null || (!param.equalsIgnoreCase("true") && !param.equalsIgnoreCase("false"))) {
param = getShowWelcomeString();
}
if (param != null && (param.equalsIgnoreCase("true") || param.equalsIgnoreCase("false"))) {
showWelcome = Boolean.parseBoolean(param);
}
if (showWelcome) {
// Check local storage
int version = getBuildVersion();
String welcomeObj = LocalDataServiceImpl.getInstance().getObjectString(EnumDataMap.WELCOME_FLAG.getDataName());
AutoBean<?> bean = AutoBeanService.getInstance().fromJsonString(EnumDataMap.WELCOME_FLAG.getClazz(), welcomeObj);
Integer welcomeVersion = -1;
WelcomeFlag welcomeFlag = null;
if (bean != null) {
welcomeFlag = (WelcomeFlag)bean.as();
welcomeVersion = welcomeFlag.getWelcomeVersion() == null ? welcomeVersion : welcomeFlag.getWelcomeVersion();
}
showWelcome = welcomeVersion < version;
}
return showWelcome;
}
示例12: testReferenceFollowing
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/**
* Create a chain of schema references and verify that the dereferencing works
* properly.
*/
@SuppressWarnings("unchecked")
public void testReferenceFollowing() {
Schema startingPoint = EasyMock.createMock(Schema.class);
EasyMock.expect(startingPoint.getRef()).andReturn("Interstitial");
AutoBean<Schema> bean = EasyMock.createMock(AutoBean.class);
EasyMock.expect(bean.as()).andReturn(startingPoint);
Schema interstitial = EasyMock.createMock(Schema.class);
EasyMock.expect(interstitial.getRef()).andReturn("Concrete");
Schema concrete = EasyMock.createMock(Schema.class);
EasyMock.expect(concrete.getRef()).andReturn(null);
EasyMock.expect(concrete.getId()).andReturn("Concrete");
Map<String, Schema> allSchemas =
ImmutableMap.of("Interstitial", interstitial, "Concrete", concrete);
EasyMock.replay(startingPoint, interstitial, concrete, bean);
Schema dereferenced = Schema.PropertyWrapper.followRefs(bean, allSchemas);
assertEquals(dereferenced, concrete);
assertEquals("Concrete", concrete.getId());
EasyMock.verify(startingPoint, interstitial, concrete, bean);
}
示例13: mutableForMethod
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/**
* Returns true if this property is mutable (or required) for the method
* identified by the given method identifier.
*/
public static boolean mutableForMethod(AutoBean<Schema> instance, String methodIdentifier) {
// Required properties will not be explicitly marked mutable, since
// mutablility is assumed for required properties.
return requiredForMethod(instance, methodIdentifier)
|| hasAnnotationForMethod(instance.as(), MUTABLE, methodIdentifier);
}
示例14: testService
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/** Tests that basic service information is parsed as expected. */
public void testService() {
assertEquals("moderator", service.getName());
assertEquals("v1", service.getVersion());
assertEquals("Moderator API", service.getDescription());
assertEquals("/rpc", service.getRpcPath());
assertEquals(3, service.getMethods().keySet().size());
@SuppressWarnings("unchecked")
AutoBean<RpcApiService> serviceBean = EasyMock.createMock(AutoBean.class);
EasyMock.expect(serviceBean.as()).andReturn(service).anyTimes();
EasyMock.replay(serviceBean);
assertEquals("/rpc", ApiServiceWrapper.basePath(serviceBean));
}
示例15: localName
import com.google.web.bindery.autobean.shared.AutoBean; //导入依赖的package包/类
/**
* @param instance the bean instance.
* @return the "local" part of the bean's name.
*/
public static String localName(AutoBean<? extends HasQName> instance) {
String name = instance.as().getName();
if (name == null) {
return null;
}
return NameTokens.parseQName(name)[1];
}