eclipse-ee4j / eclipse-ee4j/jersey
Support for Immutables generated value classes in Jersey-MVC
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
Java version 1.8
Jersey version 2.26
Immutables version 2.6.0
I have declared an abstract value type using the Immutables library - https://immutables.github.io/:
`import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.immutables.value.Value;
import org.immutables.value.Value.Style.ValidationMethod;
@Value.Modifiable
@Value.Style(create = "new", allParameters = true, passAnnotations = { NotEmpty.class, Length.class,
FormParam.class }, validationMethod = ValidationMethod.NONE, beanFriendlyModifiables = true)
public abstract class BIPRWSInventory2 {
@NotEmpty(message = "{inventory.biprws-trusted-user-header.required}")
@Length(max = 50, message = "{inventory.biprws-trusted-user-header.max-length}")
@FormParam("biprwsTrustedUserHeader")
public abstract String biprwsTrustedUserHeader();
@NotEmpty(message = "{inventory.boss-header.required}")
@Length(max = 30, message = "{inventory.boss-header.max-length}")
@FormParam("BOSSHeader")
public abstract String BOSSHeader();
@NotEmpty(message = "{inventory.ess-header.required}")
@Length(max = 30, message = "{inventory.ess-header.max-length}")
@FormParam("ESSHeader")
public abstract String ESSHeader();
}`
This results in the following generated class:
`import java.lang.String;
/**
* A modifiable implementation of the {@link BIPRWSInventory2 BIPRWSInventory2} type.
*
Use the constructor to create new modifiable instances. You may even extend this class to
* add some convenience methods, however most of the methods in this class are final
* to preserve safety and predictable invariants.
*
ModifiableBIPRWSInventory2 is not thread-safe
*/
@SuppressWarnings({"all"})
@javax.annotation.Generated({"Modifiables.generator", "BIPRWSInventory2"})
public class ModifiableBIPRWSInventory2 extends com.launchworks.launchbiadmin.model.BIPRWSInventory2 {
private java.lang.String biprwsTrustedUserHeader;
private java.lang.String BOSSHeader;
private java.lang.String ESSHeader;
/**
* Construct a modifiable instance of {@code BIPRWSInventory2}.
* @param biprwsTrustedUserHeader The value for the {@code biprwsTrustedUserHeader} attribute (can be {@code null})
* @param BOSSHeader The value for the {@code BOSSHeader} attribute (can be {@code null})
* @param ESSHeader The value for the {@code ESSHeader} attribute (can be {@code null})
*/
public ModifiableBIPRWSInventory2(java.lang.String biprwsTrustedUserHeader, java.lang.String BOSSHeader, java.lang.String ESSHeader) {
setBiprwsTrustedUserHeader(biprwsTrustedUserHeader);
setBOSSHeader(BOSSHeader);
setESSHeader(ESSHeader);
}
/**
* Construct a modifiable instance of {@code BIPRWSInventory2}.
*/
public ModifiableBIPRWSInventory2() {}
/**
* @return value of {@code biprwsTrustedUserHeader} attribute, may be {@code null}
*/
@org.hibernate.validator.constraints.NotEmpty(message = "{inventory.biprws-trusted-user-header.required}")
@org.hibernate.validator.constraints.Length(max = 50, message = "{inventory.biprws-trusted-user-header.max-length}")
@javax.ws.rs.FormParam("biprwsTrustedUserHeader")
@Override
public final java.lang.String biprwsTrustedUserHeader() {
return biprwsTrustedUserHeader;
}
/**
* @return value of {@code BOSSHeader} attribute, may be {@code null}
*/
@org.hibernate.validator.constraints.NotEmpty(message = "{inventory.boss-header.required}")
@org.hibernate.validator.constraints.Length(max = 30, message = "{inventory.boss-header.max-length}")
@javax.ws.rs.FormParam("BOSSHeader")
@Override
public final java.lang.String BOSSHeader() {
return BOSSHeader;
}
/**
* @return value of {@code ESSHeader} attribute, may be {@code null}
*/
@org.hibernate.validator.constraints.NotEmpty(message = "{inventory.ess-header.required}")
@org.hibernate.validator.constraints.Length(max = 30, message = "{inventory.ess-header.max-length}")
@javax.ws.rs.FormParam("ESSHeader")
@Override
public final java.lang.String ESSHeader() {
return ESSHeader;
}
/**
* Clears the object by setting all attributes to their initial values.
* @return {@code this} for use in a chained invocation
*/
public void clear() {
biprwsTrustedUserHeader = null;
BOSSHeader = null;
ESSHeader = null;
return;
}
/**
* Fill this modifiable instance with attribute values from the provided {@link BIPRWSInventory2} instance.
* Regular attribute values will be overridden, i.e. replaced with ones of an instance.
* Any of the instance's absent optional values will not be copied (will not override current values).
* @param instance The instance from which to copy values
* @return {@code this} for use in a chained invocation
*/
public ModifiableBIPRWSInventory2 from(com.launchworks.launchbiadmin.model.BIPRWSInventory2 instance) {
java.util.Objects.requireNonNull(instance, "instance");
java.lang.String biprwsTrustedUserHeaderValue = instance.biprwsTrustedUserHeader();
if (biprwsTrustedUserHeaderValue != null) {
setBiprwsTrustedUserHeader(biprwsTrustedUserHeaderValue);
}
java.lang.String BOSSHeaderValue = instance.BOSSHeader();
if (BOSSHeaderValue != null) {
setBOSSHeader(BOSSHeaderValue);
}
java.lang.String ESSHeaderValue = instance.ESSHeader();
if (ESSHeaderValue != null) {
setESSHeader(ESSHeaderValue);
}
return this;
}
/**
* Assigns a value to the {@code biprwsTrustedUserHeader} attribute.
* @param biprwsTrustedUserHeader The value for biprwsTrustedUserHeader, can be {@code null}
* @return {@code this} for use in a chained invocation
*/
public void setBiprwsTrustedUserHeader(java.lang.String biprwsTrustedUserHeader) {
this.biprwsTrustedUserHeader = biprwsTrustedUserHeader;
return;
}
/**
* Assigns a value to the {@code BOSSHeader} attribute.
* @param BOSSHeader The value for BOSSHeader, can be {@code null}
* @return {@code this} for use in a chained invocation
*/
public void setBOSSHeader(java.lang.String BOSSHeader) {
this.BOSSHeader = BOSSHeader;
return;
}
/**
* Assigns a value to the {@code ESSHeader} attribute.
* @param ESSHeader The value for ESSHeader, can be {@code null}
* @return {@code this} for use in a chained invocation
*/
public void setESSHeader(java.lang.String ESSHeader) {
this.ESSHeader = ESSHeader;
return;
}
/**
* Returns {@code true} if all required attributes are set, indicating that the object is initialized.
* @return {@code true} if set
*/
public final boolean isInitialized() {
return true;
}
/**
* This instance is equal to all instances of {@code ModifiableBIPRWSInventory2} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(Object another) {
if (this == another) return true;
if (!(another instanceof ModifiableBIPRWSInventory2)) return false;
ModifiableBIPRWSInventory2 other = (ModifiableBIPRWSInventory2) another;
return equalTo(other);
}
private boolean equalTo(ModifiableBIPRWSInventory2 another) {
return java.util.Objects.equals(biprwsTrustedUserHeader, another.biprwsTrustedUserHeader)
&& java.util.Objects.equals(BOSSHeader, another.BOSSHeader)
&& java.util.Objects.equals(ESSHeader, another.ESSHeader);
}
/**
* Computes a hash code from attributes: {@code biprwsTrustedUserHeader}, {@code BOSSHeader}, {@code ESSHeader}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + java.util.Objects.hashCode(biprwsTrustedUserHeader);
h += (h << 5) + java.util.Objects.hashCode(BOSSHeader);
h += (h << 5) + java.util.Objects.hashCode(ESSHeader);
return h;
}
/**
* Generates a string representation of this {@code BIPRWSInventory2}.
* If uninitialized, some attribute values may appear as question marks.
* @return A string representation
*/
@Override
public String toString() {
return "ModifiableBIPRWSInventory2{"
+ "biprwsTrustedUserHeader=" + biprwsTrustedUserHeader()
+ ", BOSSHeader=" + BOSSHeader()
+ ", ESSHeader=" + ESSHeader()
+ "}";
}
}`
When I post a form body and try to bind it to a bean using the @BeanParam and @FormParam annotations, I end up with an object will all null attributes
Contributor guide
Assessment
This issue has not been assessed yet.