com.github.longdt.vertxservice.util.ImmutableJsonArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-service4j Show documentation
Show all versions of vertx-service4j Show documentation
A lightweight replacement for vertx-service-proxy. This library is highly optimized for vertx java
package com.github.longdt.vertxservice.util;
import io.vertx.core.json.JsonArray;
import io.vertx.core.shareddata.Shareable;
import java.util.Collections;
public class ImmutableJsonArray extends JsonArray {
private final Object[] objects;
private ImmutableJsonArray(Object... objects) {
super(Collections.emptyList());
this.objects = objects;
}
public static ImmutableJsonArray of(Object... objects) {
return new ImmutableJsonArray(objects);
}
@SuppressWarnings("unchecked")
public T getObject(int index) {
return (T) objects[index];
}
@Override
public ImmutableJsonArray copy() {
Object[] copies = new Object[objects.length];
Object obj;
for (int i = 0; i < copies.length; ++i) {
obj = objects[i];
if (obj instanceof Shareable) {
obj = ((Shareable) obj).copy();
}
copies[i] = obj;
}
return new ImmutableJsonArray(copies);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy