本文整理汇总了Java中com.github.drapostolos.typeparser.TypeParser类的典型用法代码示例。如果您正苦于以下问题:Java TypeParser类的具体用法?Java TypeParser怎么用?Java TypeParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeParser类属于com.github.drapostolos.typeparser包,在下文中一共展示了TypeParser类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getParam
import com.github.drapostolos.typeparser.TypeParser; //导入依赖的package包/类
@Before
@HandleErrors({
@HandleError(code = 400, exception = TypeParserException.class, description = "params error")
})
public void getParam() {
context.putCustom("param", annotation.value());
Map<String, String> map = context.getCustom("path-params");
if (map == null) {
context.setInjectorVariable(null);
return;
}
String param = map.get(annotation.value());
if (param == null || param.equals("")) {
return;
}
TypeParser parser = TypeParser.newBuilder().build();
context.setInjectorVariable(parser.parse(param, context.getInjectorVariableType()));
}
开发者ID:wb14123,项目名称:bard,代码行数:19,代码来源:PathParamInjector.java
示例2: getJsonParam
import com.github.drapostolos.typeparser.TypeParser; //导入依赖的package包/类
@HandleErrors({
@HandleError(code = BardBasicError.READ_JSON_ERROR,
exception = JsonMappingException.class,
description = "Read JSON data error"),
@HandleError(code = 400, exception = TypeParserException.class, description = "params error")
})
@Before public void getJsonParam() throws IOException {
context.putCustom("param", annotation.value());
HashMap<String, Object> jsonMap = context.getCustom("jsonParam");
if (jsonMap == null) {
JsonFactory factory = new JsonFactory();
ObjectMapper mapper = new ObjectMapper(factory);
TypeReference<HashMap<String, Object>> typeRef =
new TypeReference<HashMap<String, Object>>() {
};
jsonMap = mapper.readValue(context.getRequest().getInputStream(), typeRef);
context.putCustom("jsonParam", jsonMap);
}
TypeParser parser = TypeParser.newBuilder().build();
Object v = jsonMap.get(annotation.value());
if (v == null) {
return;
}
context.setInjectorVariable(parser.parse(v.toString(), context.getInjectorVariableType()));
}
开发者ID:wb14123,项目名称:bard,代码行数:27,代码来源:JsonParamInjector.java
示例3: findByColumn
import com.github.drapostolos.typeparser.TypeParser; //导入依赖的package包/类
@Override public List<T> findByColumn(String columnName, String value)
throws IllegalColumnException {
CriteriaBuilder criteriaBuilder = em().getCriteriaBuilder();
CriteriaQuery<T> criteria = criteriaBuilder.createQuery(type);
Root<T> tRoot = criteria.from(type);
criteria.select(tRoot);
TypeParser typeParser = TypeParser.newBuilder().build();
Optional<Field> field = FieldFinder.of(type).getField(columnName);
if (!field.isPresent()) {
throw new IllegalColumnException(
String.format("Type %s does not hold column %s", type, columnName));
}
Object o = typeParser.parseType(value, field.get().getType());
criteria.where(criteriaBuilder.equal(tRoot.get(columnName), o));
return em().createQuery(criteria).getResultList();
}
开发者ID:cloudiator,项目名称:colosseum,代码行数:20,代码来源:BaseModelRepositoryJpa.java
示例4: getProperty
import com.github.drapostolos.typeparser.TypeParser; //导入依赖的package包/类
@Override
public <T> T getProperty(String key, Class<T> type) {
String propertyStr = getProperty(key);
try {
TypeParser parser = TypeParser.newBuilder().build();
return parser.parse(propertyStr, type);
} catch (TypeParserException | NoSuchRegisteredParserException e) {
throw new IllegalArgumentException("Unable to cast value \'" + propertyStr + "\' to " + type, e);
}
}
开发者ID:cfg4j,项目名称:cfg4j,代码行数:12,代码来源:SimpleConfigurationProvider.java
示例5: getParams
import com.github.drapostolos.typeparser.TypeParser; //导入依赖的package包/类
@Before
@HandleErrors({
@HandleError(code = 400, exception = TypeParserException.class, description = "params error")
})
public void getParams() {
context.putCustom("param", annotation.value());
String param = context.getRequest().getParameter(annotation.value());
if (param == null || param.equals("")) {
return;
}
TypeParser parser = TypeParser.newBuilder().build();
context.setInjectorVariable(parser.parse(param, context.getInjectorVariableType()));
}
开发者ID:wb14123,项目名称:bard,代码行数:14,代码来源:QueryParamInjector.java
示例6: setDefault
import com.github.drapostolos.typeparser.TypeParser; //导入依赖的package包/类
@Before public void setDefault() {
if (context.getInjectorVariable() == null) {
TypeParser parser = TypeParser.newBuilder().build();
context.setInjectorVariable(
parser.parse(annotation.value(), context.getInjectorVariableType()));
}
}
开发者ID:wb14123,项目名称:bard,代码行数:8,代码来源:DefaultValueInjector.java
示例7: get
import com.github.drapostolos.typeparser.TypeParser; //导入依赖的package包/类
@Before
public void get() {
context.putCustom("param", annotation.value());
String param = context.getRequest().getHeader(annotation.value());
if (param == null || param.equals("")) {
return;
}
TypeParser parser = TypeParser.newBuilder().build();
context.setInjectorVariable(parser.parse(param, context.getInjectorVariableType()));
}
开发者ID:wb14123,项目名称:bard,代码行数:11,代码来源:HeaderParamInjector.java
示例8: registerStandardListeners
import com.github.drapostolos.typeparser.TypeParser; //导入依赖的package包/类
/**
* Registers the standard listeners to {@link gg.al.config.IConfigKey} changed events, which are native only to desktop.
*
* @param editor the {@link gg.al.config.ConfigEditor} which is linked to the {@link Config} object
* @param cfg the {@link Config} object
* @param config the {@link LwjglApplicationConfiguration} object
* @param application the {@link LwjglApplication} to alter
*/
public static void registerStandardListeners(DesktopConfigEditor editor, Config cfg, LwjglApplicationConfiguration config, LwjglApplication application) {
TypeParser parser = TypeParser.newBuilder().build();
if (cfg.miscellaneous.logConfigEvents())
editor.addConfigValueChangedListener((key, value) -> log.debug("Config value changed: {}={}", key, value));
editor.addConfigValueChangedListener(IVideoConfig.VideoKeys.screenmode, (key, value) -> {
IVideoConfig.ScreenMode mode = parser.parse(value, IVideoConfig.ScreenMode.class);
switch (mode) {
case Fullscreen:
application.postRunnable(() -> {
application.getGraphics().setFullscreenMode(application.getGraphics().getDisplayMode());
editor.setValue(IVideoConfig.VideoKeys.width, application.getGraphics().getWidth());
editor.setValue(IVideoConfig.VideoKeys.width, application.getGraphics().getWidth());
editor.flush();
});
break;
case Borderless:
application.postRunnable(() -> {
application.getGraphics().setFullscreenMode(application.getGraphics().getDisplayMode());
application.getGraphics().setUndecorated(true);
application.getGraphics().setWindowedMode(cfg.video.width(), cfg.video.height());
editor.setValue(IVideoConfig.VideoKeys.width, application.getGraphics().getWidth());
editor.setValue(IVideoConfig.VideoKeys.width, application.getGraphics().getWidth());
editor.flush();
});
break;
case Windowed:
application.postRunnable(() -> {
application.getGraphics().setFullscreenMode(application.getGraphics().getDisplayMode());
application.getGraphics().setUndecorated(false);
application.getGraphics().setWindowedMode(cfg.video.width(), cfg.video.height());
});
break;
}
}, true);
editor.addConfigValueChangedListener(IVideoConfig.VideoKeys.backgroundFPS, (key, value) -> config.backgroundFPS = parser.parse(value, Integer.class));
editor.addConfigValueChangedListener(IVideoConfig.VideoKeys.foregroundFPS, (key, value) -> config.foregroundFPS = parser.parse(value, Integer.class));
editor.addConfigValueChangedListener(IVideoConfig.VideoKeys.vsyncEnabled, (key, value) -> application.postRunnable(() -> application.getGraphics().setVSync(parser.parse(value, Boolean.class))));
editor.addConfigValueChangedListener(IVideoConfig.VideoKeys.width, ((key, value) -> application.postRunnable(() -> {
if (cfg.video.screenmode().isWindowed()) {
application.getGraphics().setFullscreenMode(application.getGraphics().getDisplayMode());
application.getGraphics().setUndecorated(false);
application.getGraphics().setWindowedMode(cfg.video.width(), cfg.video.height());
}
})), true);
}
开发者ID:EtherWorks,项目名称:arcadelegends-gg,代码行数:54,代码来源:DesktopConfigUtil.java
注:本文中的com.github.drapostolos.typeparser.TypeParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论