public static <T, V> Pair<T, V> make( T f, V s ) { return new Pair<>( f, s ); }
private IJsonType findFragmentType( Token token, URI uri, Pair<IJsonType, JsonSchemaTransformer> pair ) { String fragment = uri.getFragment(); IJsonType baseType = pair.getFirst(); if( fragment == null || fragment.isEmpty() ) { return baseType; } return pair.getSecond().findFragmentRef( (JsonSchemaType)baseType, ((JsonSchemaType)baseType).getFile(), token, uri ); }
public void enterElement( XMLParser.ElementContext ctx ) { XmlElement parent = _elements.isEmpty() ? null : _elements.peek().getSecond(); XmlElement xmlElement = new XmlElement( ctx, parent ); if( parent != null ) { parent.addChild( xmlElement ); } _elements.push( new Pair<>( ctx, xmlElement ) ); if( _root == null ) { _root = xmlElement; } }
public Type get( TypeVariable tvType ) { Pair<Type, Boolean> pair = _map.get( tvType ); return pair != null ? pair.getFirst() : null; }
private static List getList( Object value ) { if( value instanceof Pair ) { value = ((Pair)value).getSecond(); } return value instanceof List ? (List)value : null; }
public Type remove( TypeVariable tvType ) { Pair<Type, Boolean> pair = _map.remove( tvType ); return pair != null ? pair.getFirst() : null; }
private static Bindings getBindings( Object value ) { if( value instanceof Pair ) { value = ((Pair)value).getSecond(); } return value instanceof Bindings ? (Bindings)value : null; }
private SrcClass makeSrcClassStubFromProducedClass( String fqn, JavaFileManager.Location location ) { BasicJavacTask[] task = new BasicJavacTask[1]; Pair<Symbol.ClassSymbol, JCTree.JCCompilationUnit> pair = getClassSymbolForProducedClass( fqn, task ); if( pair == null ) { throw new NullPointerException( "Could not find ClassSymbol for: " + fqn ); } Symbol.ClassSymbol classSymbol = pair.getFirst(); return SrcClassUtil.instance().makeStub( _module, fqn, classSymbol, pair.getSecond(), task[0] ); }
public Type get( TypeVariable tvType ) { Pair<Type, Boolean> pair = _map.get( tvType ); return pair != null ? pair.getFirst() : null; }
public Type put( TypeVariable tvType, Type type, boolean bReverse ) { Type existing = remove( tvType ); _map.put( tvType, type == null ? null : new Pair<>( type, bReverse ) ); return existing; }
Boolean isNullable( List list ) { for( Object elem: list ) { if( elem instanceof Pair ) { elem = ((Pair)elem).getSecond(); } if( "null".equals( ((Bindings)elem).get( JSCH_TYPE ) ) ) { return true; } } return null; }
public Type remove( TypeVariable tvType ) { Pair<Type, Boolean> pair = _map.remove( tvType ); return pair != null ? pair.getFirst() : null; }
public Type put( TypeVariable tvType, Type type, boolean bReverse ) { Type existing = remove( tvType ); _map.put( tvType, type == null ? null : new Pair<>( type, bReverse ) ); return existing; }
private static String getJSchema_Name( Bindings docObj ) { Object value = docObj.get( JSCH_NAME ); String name; if( value instanceof Pair ) { name = (String)((Pair)value).getSecond(); } else { name = (String)value; } return name; }
@Override public void exitElement( XMLParser.ElementContext ctx ) { Pair<XMLParser.ElementContext, XmlElement> popped = _elements.pop(); if( popped.getFirst() != ctx ) { throw new IllegalStateException( "Unbalanced elements, expecting '" + ctx.Name( 0 ) + "' but found '" + popped.getFirst().Name( 0 ) + "'" ); } }
/** * Splits the original collection into pair of lists, * where <i>first</i> list contains elements for which {@code predicate} yielded {@code true}, * while <i>second</i> list contains elements for which {@code predicate} yielded {@code false}. */ public static <T> Pair<List<T>, List<T>> partition( @This Iterable<T> thiz, Predicate<T> predicate ) { ArrayList<T> first = new ArrayList<T>(); ArrayList<T> second = new ArrayList<T>(); for( T element : thiz ) { if( predicate.test( element ) ) { first.add( element ); } else { second.add( element ); } } return new Pair<>( first, second ); }
private void assignAttribute( Bindings jsonObj, String attr ) { boolean hasAttr = jsonObj.containsKey( attr ); if( hasAttr ) { Object attrValue = jsonObj.get( attr ); if( attrValue instanceof Pair ) { attrValue = ((Pair)attrValue).getSecond(); } _attributes.put( attr, attrValue ); } }