org.jboss.resteasy.reactive.common.model.ResourceContextResolver Maven / Gradle / Ivy
package org.jboss.resteasy.reactive.common.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.ext.ContextResolver;
import org.jboss.resteasy.reactive.spi.BeanFactory;
public class ResourceContextResolver {
private BeanFactory> factory;
private String className;
private List mediaTypeStrings = new ArrayList<>();
private volatile List mediaTypes;
public void setFactory(BeanFactory> factory) {
this.factory = factory;
}
public BeanFactory> getFactory() {
return factory;
}
public String getClassName() {
return className;
}
public ResourceContextResolver setClassName(String className) {
this.className = className;
return this;
}
public ResourceContextResolver setMediaTypeStrings(List mediaTypeStrings) {
this.mediaTypeStrings = mediaTypeStrings;
return this;
}
public List getMediaTypeStrings() {
return mediaTypeStrings;
}
public List mediaTypes() {
if (mediaTypes == null) {
//todo: does this actually need to be threadsafe?
synchronized (this) {
List ret = new ArrayList<>();
for (String i : mediaTypeStrings) {
ret.add(MediaType.valueOf(i));
}
mediaTypes = Collections.unmodifiableList(ret);
}
}
return mediaTypes;
}
}