/** * Method get returns a new Tuple populated with only those values whose field names are specified * in the given selector. The declarator Fields instance declares the fields and positions in the * current Tuple instance. * * @param declarator of type Fields * @param selector of type Fields * @return Tuple */ public Tuple get(Fields declarator, Fields selector) { if (!declarator.isUnknown() && elements.size() != declarator.size()) throw new TupleException( "field declaration: " + declarator.print() + ", does not match tuple: " + print()); return get(declarator.getPos(selector, size())); }
@Override public Fields serialize(final Object o) { if (!set.contains(o.getClass())) throw new IllegalArgumentException(); final Fields f = new Fields(); if (o instanceof Collection) { final Collection<?> c = ((Collection<?>) o); f.putObject("values", c.toArray()); } else if (o instanceof Map) { final Map<?, ?> m = ((Map<?, ?>) o); f.putObject("keys", m.keySet().toArray()); f.putObject("values", m.values().toArray()); } assert f.size() > 0 : o; return f; }