/** * Deserialize a {@link Class}-tagged {@link JSONObject} that should correspond to a {@link JsonSerializable}. * * @param jsonObject the {@link JSONObject} * @return the deserialization product */ @SuppressWarnings("unchecked") public static <T> T deserialize(JSONObject jsonObject) { if (isJsonNull(jsonObject)) return null; return deserialize(jsonObject, JsonSerializable.uncheckedSerializer()); }
/** * Serialize the given {@link Object} using a specific {@link JsonSerializer}. * * @param obj the {@link Object} to serialize * @param isPolymorph in case a {@link JSONObject} is created, whether it should be tagged with the {@link Class} * of {@code serializable} * @param serializer the {@link JsonSerializer} * @return the serialization result */ public static <T> JSONObject serialize(T obj, boolean isPolymorph, JsonSerializer<T> serializer) { return addClassTag(obj, serializer.serialize(obj), isPolymorph); }
/** * Deserialize a {@link JSONArray} according to the rules of {@link #deserialize(JSONObject, Class)}. * * @param jsonArray the {@link JSONArray} * @param cls the {@link Class} of the elements in the {@code jsonArray} * @return the deserialization product */ @SuppressWarnings("unchecked") public static <T> List<T> deserializeAllAsList(JSONArray jsonArray, Class<T> cls) { return deserializeAllAsList(jsonArray, (JsonSerializer<T>) JsonSerializable.uncheckedSerializer(), cls); }
public static Tuple<OutputSlot<?>, OptimizationContext> createConcatenationKey( OutputSlot<?> outputSlot, OptimizationContext optimizationContext) { return new Tuple<>(outputSlot, optimizationContext); }
/** * Deserialize a ({@link Class}-tagged) {@link JSONObject} with a {@link JsonSerializer}. * * @param jsonObject the {@link JSONObject} * @param serializer the {@link JsonSerializer} * @return the deserialization product */ public static <T> T deserialize(JSONObject jsonObject, JsonSerializer<T> serializer) { if (isJsonNull(jsonObject)) return null; return serializer.deserialize(jsonObject); }
@Override public T next() { this.ensureInitialized(); T curNext = this.next; this.moveToNext(); return curNext; }
/** * Creates the new instance that merges this and the given one via logical AND. * * @param that the other instance * @return this merged instance */ public Bitmask and(Bitmask that) { Bitmask copy = new Bitmask(this, that.bits.length << WORD_ADDRESS_BITS); return copy.andInPlace(that); }
/** * Gets the bit at the given index. * * @param index where the bit should be set * @return whether the bit in question is set */ public boolean get(int index) { final int longPos = getLongPos(index); if (longPos >= this.bits.length) return false; final int offset = getOffset(index); return ((this.bits[longPos] >>> offset) & 1) != 0; }
@Override public int nextInt() { if (!this.hasNext()) throw new NoSuchElementException(); int result = this.next; this.next = Bitmask.this.nextSetBit(this.next + 1); return result; }
/** * Create a new instance. */ PlanImplementation( PlanEnumeration planEnumeration, Map<OutputSlot<?>, Junction> junctions, Collection<ExecutionOperator> operators, OptimizationContext optimizationContext) { this(planEnumeration, junctions, new Canonicalizer<>(operators), optimizationContext); }
/** * Enumerates in ascending order all integers {@code 0 <= i < to}. */ public static int[] range(int to) { return range(0, to); }
/** * Creates a new instance. * * @param startCapacity the number of bits (starting from {@code 0}) that should already be held available */ public Bitmask(int startCapacity) { int numLongs = startCapacity > 0 ? getLongPos(startCapacity - 1) + 1 : 0; this.bits = new long[numLongs]; this.cardinalityCache = 0; }
/** * Executes an {@link Action}, catching any error. * * @param action to be executed */ public static void doSafe(Action action) { action.executeSafe(); }
private void ensureInitialized() { // We need to lazy-intialize to prevent deadlocks on instantiation. if (!this.isInitialized) { this.moveToNext(); this.isInitialized = true; } }
/** * Serialize the given {@link JsonSerializable}. * * @param serializable the {@link JsonSerializable} to serialize * @param isPolymorph in case a {@link JSONObject} is created, whether it should be tagged with the {@link Class} * of {@code serializable} * @return the serialization result */ public static JSONObject serialize(JsonSerializable serializable, boolean isPolymorph) { return serialize(serializable, isPolymorph, JsonSerializable.uncheckedSerializer); }
/** * Tells whether the given instance is a JSON datatype. * * @param obj the instance to test * @return whether {@code obj} is a JSON datatype */ public static boolean isJsonCompatible(Object obj) { return isUnconvertedInstance(obj) || obj == JSONObject.NULL || obj instanceof JSONObject || obj instanceof JSONArray; }
/** * Tells whether this instance is empty. * * @return whether this instance is empty */ public boolean isEmpty() { return this.cardinality() == 0; }
/** * Deserialize a {@link JSONObject} that should correspond to a {@link JsonSerializable}. * * @param jsonObject the {@link JSONObject} * @param cls the {@link Class} of the deserialization product * @return the deserialization product */ @SuppressWarnings("unchecked") public static <T> T deserialize(JSONObject jsonObject, Class<? extends T> cls) { if (isJsonNull(jsonObject)) return null; return deserialize(jsonObject, (JsonSerializer<T>) JsonSerializable.uncheckedSerializer(), cls); }
/** * Creates new instance. */ PlanImplementation(PlanEnumeration planEnumeration, Map<OutputSlot<?>, Junction> junctions, OptimizationContext optimizationContext) { this(planEnumeration, junctions, new Canonicalizer<>(), optimizationContext); }