/** * Adds a value to this set if the boolean value is <jk>true</jk> * * @param b The boolean value. * @param t The value to add. * @return This object (for method chaining). */ public ASet<T> appendIf(boolean b, T t) { if (b) append(t); return this; } }
@Override /* SwaggerElement */ public Set<String> keySet() { ASet<String> s = new ASet<String>() .appendIf(title != null, "title") .appendIf(description != null, "description") .appendIf(termsOfService != null, "termsOfService") .appendIf(contact != null, "contact") .appendIf(license != null, "license") .appendIf(version != null, "version"); return new MultiSet<>(s, super.keySet()); } }
/** * Test method for {@link Operation#produces(java.lang.Object[])}. */ @Test public void testProduces() { Operation t = new Operation(); t.produces(new ASet<MediaType>().appendAll(MediaType.forString("text/foo"))); t.produces(MediaType.forString("text/bar")); t.produces("text/baz"); t.produces(new StringBuilder("text/qux")); t.produces((Object)new String[]{"text/quux"}); t.produces((Object)new ASet<String>().append("text/quuux")); t.produces("['text/quuuux']"); t.produces("[]"); t.produces((Object)null); assertObjectEquals("['text/foo','text/bar','text/baz','text/qux','text/quux','text/quuux','text/quuuux']", t.getProduces()); assertInstanceOf(List.class, t.getProduces()); for (MediaType mt : t.getProduces()) assertInstanceOf(MediaType.class, mt); }
public A init() { f1 = AEnum.FOO; f2 = AEnum.BAR; f3 = new AEnum[]{AEnum.FOO,null}; f4 = new AEnum[][]{{AEnum.FOO,null},null}; f5 = new AList<AEnum>().append(AEnum.FOO); f6 = new AList<AEnum>().append(AEnum.FOO); f7 = new ASet<AEnum>().append(AEnum.FOO); f8 = new ASet<AEnum>().append(AEnum.FOO); return this; } }
private static Set<String> toSet(String[] ss) throws ParseException { if (ss.length == 0) return null; String s = joinnl(ss); if (s.isEmpty()) return null; Set<String> set = new ASet<>(); for (Object o : StringUtils.parseListOrCdl(s)) set.add(o.toString()); return set; }
/** * Adds multiple entries to this set. * * @param t The entries to add to this set. * @return This object (for method chaining). */ public ASet<T> appendAll(T...t) { addAll(Arrays.asList(t)); return this; }
/** * Adds an entry to this set. * * @param t The entry to add to this set. * @return This object (for method chaining). */ public ASet<T> append(T t) { add(t); return this; }
@Override /* SwaggerElement */ public Set<String> keySet() { ASet<String> s = new ASet<String>() .appendIf(title != null, "title") .appendIf(description != null, "description") .appendIf(termsOfService != null, "termsOfService") .appendIf(contact != null, "contact") .appendIf(license != null, "license") .appendIf(version != null, "version"); return new MultiSet<>(s, super.keySet()); } }
/** * Test method for {@link Swagger#consumes(java.lang.Object[])}. */ @Test public void testConsumes() { Swagger t = new Swagger(); t.consumes(new ASet<MediaType>().appendAll(MediaType.forString("text/foo"))); t.consumes(MediaType.forString("text/bar")); t.consumes("text/baz"); t.consumes(new StringBuilder("text/qux")); t.consumes((Object)new String[]{"text/quux"}); t.consumes((Object)new ASet<String>().append("text/quuux")); t.consumes("['text/quuuux']"); t.consumes("[]"); t.consumes((Object)null); assertObjectEquals("['text/foo','text/bar','text/baz','text/qux','text/quux','text/quuux','text/quuuux']", t.getConsumes()); assertInstanceOf(List.class, t.getConsumes()); for (MediaType mt : t.getConsumes()) assertInstanceOf(MediaType.class, mt); }
public B init() { f1 = BEnum.FOO; f2 = BEnum.BAR; f3 = new BEnum[]{BEnum.FOO,null}; f4 = new BEnum[][]{{BEnum.FOO,null},null}; f5 = new AList<BEnum>().append(BEnum.FOO); f6 = new AList<BEnum>().append(BEnum.FOO); f7 = new ASet<BEnum>().append(BEnum.FOO); f8 = new ASet<BEnum>().append(BEnum.FOO); return this; } }
final static Set<String> toSet(String s) { if (isEmpty(s)) return null; Set<String> set = new ASet<>(); try { for (Object o : StringUtils.parseListOrCdl(s)) set.add(o.toString()); } catch (ParseException e) { throw new RuntimeException(e); } return set; }
/** * Adds multiple entries to this set. * * @param t The entries to add to this set. * @return This object (for method chaining). */ public ASet<T> appendAll(T...t) { addAll(Arrays.asList(t)); return this; }
/** * Adds an entry to this set. * * @param t The entry to add to this set. * @return This object (for method chaining). */ public ASet<T> append(T t) { add(t); return this; }
@Override /* SwaggerElement */ public Set<String> keySet() { ASet<String> s = new ASet<String>() .appendIf(name != null, "name") .appendIf(namespace != null, "namespace") .appendIf(prefix != null, "prefix") .appendIf(attribute != null, "attribute") .appendIf(wrapped != null, "wrapped"); return new MultiSet<>(s, super.keySet()); } }
/** * Test method for {@link Operation#parameters(java.lang.Object[])}. */ @Test public void testParameters() { Operation t = new Operation(); t.parameters(new ASet<ParameterInfo>().appendAll(parameterInfo("a1","a2"))); t.parameters(parameterInfo("b1","b2")); t.parameters("{in:'c1',name:'c2'}"); t.parameters(new StringBuilder("{in:'d1',name:'d2'}")); t.parameters((Object)new String[]{"{in:'e1',name:'e2'}"}); t.parameters((Object)new ASet<String>().append("{in:'f1',name:'f2'}")); t.parameters("[{in:'g1',name:'g2'}]"); t.parameters("[]"); t.parameters((Object)null); assertObjectEquals("[{'in':'a1',name:'a2'},{'in':'b1',name:'b2'},{'in':'c1',name:'c2'},{'in':'d1',name:'d2'},{'in':'e1',name:'e2'},{'in':'f1',name:'f2'},{'in':'g1',name:'g2'}]", t.getParameters()); assertInstanceOf(List.class, t.getParameters()); for (ParameterInfo pi : t.getParameters()) assertInstanceOf(ParameterInfo.class, pi); }
/** * Test method for {@link Operation#securities(java.lang.Object[])}. */ @Test public void testSecurities() { Operation t = new Operation(); t.securities(new ASet<Map<String,List<String>>>().append(new AMap<String,List<String>>().append("a1",new AList<String>().append("a2")))); t.securities(new AMap<String,List<String>>().append("b1",new AList<String>().append("b2"))); t.securities("{c1:['c2']}"); t.securities(new StringBuilder("{d1:['d2']}")); t.securities((Object)new String[]{"{e1:['e2']}"}); t.securities((Object)new ASet<String>().append("{f1:['f2']}")); t.securities("[{g1:['g2']}]"); t.securities("[]"); t.securities((Object)null); assertObjectEquals("[{a1:['a2']},{b1:['b2']},{c1:['c2']},{d1:['d2']},{e1:['e2']},{f1:['f2']},{g1:['g2']}]", t.getSecurity()); assertInstanceOf(List.class, t.getSecurity()); }