/** * Same as {@link #getProperty(String, Class, Object)} but allows for more than one default value. * * @param key The property key. * @param type The type to convert the property to. * @param def * The default values if the session property does not exist or is <jk>null</jk>. * The first non-null value is returned. * @return The session property. */ @SafeVarargs public final <T> T getProperty(String key, Class<T> type, T...def) { return getProperty(key, type, ObjectUtils.firstNonNull(def)); }
/** * Same as {@link #getProperty(String, Class, Object)} but allows for more than one default value. * * @param key The property key. * @param type The type to convert the property to. * @param def * The default values if the session property does not exist or is <jk>null</jk>. * The first non-null value is returned. * @return The session property. */ @SafeVarargs public final <T> T getProperty(String key, Class<T> type, T...def) { return getProperty(key, type, ObjectUtils.firstNonNull(def)); }
/** * Same as {@link #getProperty(String, Class, Object)} but allows for more than one default value. * * @param key The property key. * @param type The type to convert the property to. * @param def * The default values if the session property does not exist or is <jk>null</jk>. * The first non-null value is returned. * @return The session property. */ @SafeVarargs public final <T> T getProperty(String key, Class<T> type, T...def) { return getProperty(key, type, ObjectUtils.firstNonNull(def)); }
/** * Create a new session using properties specified in the context. * * @param ctx * The context creating this session object. * The context contains all the configuration settings for this object. * @param args * Runtime session arguments. */ protected BeanSession(BeanContext ctx, BeanSessionArgs args) { super(args); this.ctx = ctx; locale = ObjectUtils.firstNonNull(args.locale, ctx.getLocale(), Locale.getDefault()); timeZone = ObjectUtils.firstNonNull(args.timeZone, ctx.getTimeZone()); debug = ObjectUtils.firstNonNull(args.debug, ctx.isDebug(), false); schema = args.schema; mediaType = ObjectUtils.firstNonNull(args.mediaType, ctx.getMediaType()); }
/** * Create a new session using properties specified in the context. * * @param ctx * The context creating this session object. * The context contains all the configuration settings for this object. * @param args * Runtime session arguments. */ protected BeanSession(BeanContext ctx, BeanSessionArgs args) { super(args); this.ctx = ctx; locale = ObjectUtils.firstNonNull(args.locale, ctx.getLocale(), Locale.getDefault()); timeZone = ObjectUtils.firstNonNull(args.timeZone, ctx.getTimeZone()); debug = ObjectUtils.firstNonNull(args.debug, ctx.isDebug(), false); schema = args.schema; mediaType = ObjectUtils.firstNonNull(args.mediaType, ctx.getMediaType()); }
/** * Create a new session using properties specified in the context. * * @param ctx * The context creating this session object. * The context contains all the configuration settings for this object. * @param args * Runtime session arguments. */ protected BeanSession(BeanContext ctx, BeanSessionArgs args) { super(args); this.ctx = ctx; locale = ObjectUtils.firstNonNull(args.locale, ctx.getLocale(), Locale.getDefault()); timeZone = ObjectUtils.firstNonNull(args.timeZone, ctx.getTimeZone()); debug = ObjectUtils.firstNonNull(args.debug, ctx.isDebug(), false); schema = args.schema; mediaType = ObjectUtils.firstNonNull(args.mediaType, ctx.getMediaType()); }
Class<T> c = (Class<T>)rbm.getClassMeta().getInnerClass(); final RestClient rc = this.client; final HttpPartParser p = ObjectUtils.firstNonNull(partParser, rc.getPartParser()); return (T)Proxy.newProxyInstance( c.getClassLoader(),
Class<T> c = (Class<T>)rbm.getClassMeta().getInnerClass(); final RestClient rc = this.client; final HttpPartParser p = ObjectUtils.firstNonNull(partParser, rc.getPartParser()); return (T)Proxy.newProxyInstance( c.getClassLoader(),
Class<T> c = (Class<T>)rbm.getClassMeta().getInnerClass(); final RestClient rc = this.client; final HttpPartParser p = ObjectUtils.firstNonNull(partParser, rc.getPartParser()); return (T)Proxy.newProxyInstance( c.getClassLoader(),
LogManager.getLogManager().reset(); this.logger = Logger.getLogger(""); String logFile = firstNonNull(logConfig.logFile, config.getString("Logging/logFile")); String logDir = firstNonNull(logConfig.logDir, config.getString("Logging/logDir", ".")); mkdirs(new File(logDir), false); boolean append = firstNonNull(logConfig.append, config.getBoolean("Logging/append")); int limit = firstNonNull(logConfig.limit, config.getInt("Logging/limit", 1024*1024)); int count = firstNonNull(logConfig.count, config.getInt("Logging/count", 1)); fh.setLevel(firstNonNull(logConfig.fileLevel, config.getObjectWithDefault("Logging/fileLevel", Level.INFO, Level.class))); logger.addHandler(fh); ch.setLevel(firstNonNull(logConfig.consoleLevel, config.getObjectWithDefault("Logging/consoleLevel", Level.WARNING, Level.class))); ch.setFormatter(f); logger.addHandler(ch);
@Override /* HttpPartParser */ public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> type) throws ParseException, SchemaValidationException { schema = ObjectUtils.firstNonNull(schema, getSchema(), DEFAULT_SCHEMA); T t = parseInner(partType, schema, in, type); if (t == null && type.isPrimitive()) t = type.getPrimitiveDefault(); schema.validateOutput(t, ctx); return t; }
@Override public void onSet(Object o) { try { ResponsePartMeta rpm = req.getResponseHeaderMeta(o); if (rpm == null) rpm = ResponseHeaderObject.this.meta; res.setHeader(new HttpPart(name, HttpPartType.HEADER, rpm.getSchema(), firstNonNull(rpm.getSerializer(), req.getPartSerializer()), req.getSerializerSessionArgs(), o)); } catch (SerializeException | SchemaValidationException e) { throw new RuntimeException(e); } } });
@Override /* HttpPartParser */ public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> type) throws ParseException, SchemaValidationException { schema = ObjectUtils.firstNonNull(schema, getSchema(), DEFAULT_SCHEMA); T t = parseInner(partType, schema, in, type); if (t == null && type.isPrimitive()) t = type.getPrimitiveDefault(); schema.validateOutput(t, ctx); return t; }
@Override public void onSet(Object o) { try { ResponsePartMeta rpm = req.getResponseHeaderMeta(o); if (rpm == null) rpm = ResponseHeaderObject.this.meta; res.setHeader(new HttpPart(name, HttpPartType.HEADER, rpm.getSchema(), firstNonNull(rpm.getSerializer(), req.getPartSerializer()), req.getSerializerSessionArgs(), o)); } catch (SerializeException | SchemaValidationException e) { throw new RuntimeException(e); } } });
@Override public void onSet(Object o) { try { ResponsePartMeta rpm = req.getResponseHeaderMeta(o); if (rpm == null) rpm = ResponseHeaderObject.this.meta; res.setHeader(new HttpPart(name, HttpPartType.HEADER, rpm.getSchema(), firstNonNull(rpm.getSerializer(), req.getPartSerializer()), req.getSerializerSessionArgs(), o)); } catch (SerializeException | SchemaValidationException e) { throw new RuntimeException(e); } } });
@Override /* HttpPartParser */ public <T> T parse(HttpPartType partType, HttpPartSchema schema, String in, ClassMeta<T> type) throws ParseException, SchemaValidationException { schema = ObjectUtils.firstNonNull(schema, getSchema(), DEFAULT_SCHEMA); T t = parseInner(partType, schema, in, type); if (t == null && type.isPrimitive()) t = type.getPrimitiveDefault(); schema.validateOutput(t, ctx); return t; }
VarResolver vr = getVarResolver(); int[] ports = ObjectUtils.firstNonNull(builder.ports, cf.getObjectWithDefault("Jetty/port", mf.getWithDefault("Jetty-Port", new int[]{8000}, int[].class), int[].class)); int availablePort = findOpenPort(ports); setProperty("availablePort", availablePort, false); boolean resolveVars = ObjectUtils.firstNonNull(builder.jettyXmlResolveVars, cf.getBoolean("Jetty/resolveVars"));
schema = ObjectUtils.firstNonNull(schema, DEFAULT_SCHEMA); ClassMeta<?> type = getClassMetaForObject(value); if (type == null)
schema = ObjectUtils.firstNonNull(schema, DEFAULT_SCHEMA); ClassMeta<?> type = getClassMetaForObject(value); if (type == null)
schema = ObjectUtils.firstNonNull(schema, DEFAULT_SCHEMA); ClassMeta<?> type = getClassMetaForObject(value); if (type == null)