![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
xyz.ronella.gosu:ginfuser
Advanced tools
A gosu implementation to map a domain class into a DTO *(data transfer object)*. This utilizes annotations to describe how the fields in the DTO must be populated.
A gosu implementation to map a domain class into a DTO (data transfer object). This utilizes annotations to describe how the fields in the DTO must be populated.
Annotation | Target | Description |
---|---|---|
@CalculatedFieldInfuser(sourceType: String, calculateMethod: String, calculateMethodReturnType: String, supportClass: String) | Property | Describes that the value of the property will be calculated from a method (i.e. calculateMethod) of the supportClass. The return type of the method must be specified by calculateMethodReturnType parameter. The sourceType is optional. |
@DateFieldInfuser(sourceType: String, sourceField: String, defaultValue: String) | Property | Describes that the string value of the property will be copied from a date property (i.e. sourceField) of the domain class (i.e. sourceType). The string value and the defaultValue is in the format YYYY-MM-DD. |
@InfuseFieldInfuser(sourceType: String, sourceField: String, sourceFieldType: String) | Property | Describes that the value of the property will be an output of another infusion based on the property (i.e. sourceField) of a particular type (i.e. sourceFieldType) of the domain class (i.e. sourceType). |
@SourceTypeInfuser(sourceType: String) | Class | Describes the type of the class that the DTO depends on. The sourceTypes of the other annotations are all optional. |
@StringConstantInfuser(value : String) | Property | Describes that the string property in the DTO will have a specific value identified by the value parameter. |
@StringFieldInfuser(sourceType: String, sourceField: String, defaultValue: String) | Property | Describes that the string value of the property will be copied from a string property (i.e. sourceField) of the domain class (i.e. sourceType). |
The Infuser class is the one that interprets the description and perform the necessary actions for each property in the DTO. This class can only be created by an Infuser.Builder class. This class has the following methods:
Method | Description |
---|---|
static getBuilder<TYPE_DTO_BUILD>() : Builder<TYPE_DTO_BUILD> | Returns an instance of Infuser.Builder class. |
infuse(sourceObject: Object, beanObject: TYPE_BEAN) : TYPE_BEAN | The actual method that infuse the sourceObject to the beanObject. |
The only class that can create an instance of Infuser and it can be created by invoking Infuser.getBuilder() method.
Method | Description |
---|---|
addInfuser(infuserObject : IInfuser) : Builder<TYPE_BEAN_BUILD> | Add a single implementation of IInfuser. |
addInfusers(infuserObjects : List<IInfuser>) : Builder<TYPE_BEAN_BUILD> | Add a multiple implementation of IInfusers. |
async() : Builder<TYPE_BEAN_BUILD> | The infuser method of the Infuser instance might run each property processing in parallel. |
build() : Infuser<TYPE_BEAN_BUILD> | The method the return an instance of Infuser. |
sync() : Builder<TYPE_BEAN_BUILD> | The infuser method of the Infuser instance is running the property processing in synchronous. |
Add the following maven dependency to your gosu project:
Property | Value |
---|---|
Group ID | xyz.ronella.gosu |
Artifact ID | ginfuser |
Version | 1.1.0 |
Using gradle, this can be added as a dependency entry like the following:
compile group: 'xyz.ronella.gosu', name: 'ginfuser', version: '1.1.0'
class SampleClass {
private var _field1 : String as Field1
private var _field2 : String as Field2
private var _names : List<String> as Nomenclatures = {}
private var _date : Date as StartDate
private var _enddate : Date as EndDate
private var _sampleClass2 : SampleClass2 as SubClass
}
class SampleClass2 {
private var _field1 : String as Field1
private var _field2 : String as Field2
private var _names : List<String> as Nomenclatures = {}
private var _date : Date as StartDate
}
@SourceTypeInfuser("SampleClass")
final class SampleDTO {
@StringFieldInfuser(:sourceField = "Field1", :defaultValue = "Default1")
private var _col1 : String as Column1
@StringFieldInfuser(:sourceField = "Field2")
private var _col2 : String as Column2
@CalculatedFieldInfuser(
:calculateMethod = "generateNames", :calculateMethodReturnType = "java.util.List<String>",
:supportClass = "xyz.ronella.gosu.ginfuser.dto.SampleSupport"
)
private var _names : List<String> as Names
@DateFieldInfuser(:sourceField = "StartDate")
private var _date : String as Date
@DateFieldInfuser(:sourceField = "EndDate", :defaultValue = "2021-03-17")
private var _date2 : String as Date2
@StringConstantInfuser(:value = "Constant")
private var _tmp : String as Dummy
@InfuseFieldInfuser(:sourceField = "SubClass",
:sourceFieldType = "xyz.ronella.gosu.ginfuser.business.SampleClass2"
)
private var _childClass : SampleDTO2 as ChildClass
}
@SourceTypeInfuser("SampleClass2")
class SampleDTO2 {
@StringFieldInfuser(:sourceField = "Field1",
:defaultValue = "no-value"
)
private var _col1 : String as Column1
@StringFieldInfuser(:sourceField = "Field2"
, :defaultValue = "no-value"
)
private var _col2 : String as Column2
@CalculatedFieldInfuser(
:calculateMethod = "generateNames2",
:calculateMethodReturnType = "java.util.List<String>",
:supportClass = "SampleSupport"
)
private var _names : List<String> as Names
@DateFieldInfuser(:sourceField = "StartDate"
, :defaultValue = "no-date"
)
private var _date : String as Date
@StringConstantInfuser(:value = "Constant2")
private var _tmp : String as Dummy
}
class SampleSupport {
public function generateNames(sourceObject : Object, beanObject : Object) : List<String> {
var tests : List<String> = {}
if (sourceObject typeis SampleClass) {
tests.addAll(sourceObject.Nomenclatures)
}
return tests
}
public function generateNames2(sourceObject : Object, beanObject : Object) : List<String> {
var tests : List<String> = {}
if (sourceObject typeis SampleClass2) {
tests.addAll(sourceObject.Nomenclatures)
}
return tests
}
}
var sampleClass = new SampleClass()
var sampleClass2 = new SampleClass2()
sampleClass.SubClass = sampleClass2
sampleClass.Field1 = "Field1"
sampleClass.StartDate = Date.create(2020, Month.MARCH, 17, 0, 0, 0, 0)
sampleClass.Nomenclatures = {"One", "Two"}
sampleClass2.Field1 = "SubClassTest"
var sampleDTO = Infuser.getBuilder<SampleDTO>().async().build().infuse(sampleClass, new SampleDTO())
print("sampleDTO.Column1: ${sampleDTO.Column1}")
print("sampleDTO.Date: ${sampleDTO.Date}")
print("sampleDTO.Names: ${sampleDTO.Names}")
print("sampleDTO.ChildClass.Column1: ${sampleDTO.ChildClass.Column1}")
The output will be as described in the SampleDTO class
sampleDTO.Column1: Field1
sampleDTO.Date: 2020-03-17
sampleDTO.Names: [One, Two]
sampleDTO.ChildClass.Column1: SubClassTest
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
A gosu implementation to map a domain class into a DTO *(data transfer object)*. This utilizes annotations to describe how the fields in the DTO must be populated.
We found that xyz.ronella.gosu:ginfuser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.