-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement HiddenFieldDefinitionBuilder
- Loading branch information
eschleb
committed
Mar 6, 2024
1 parent
f473638
commit dbc717c
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
.../java/com/merkle/oss/magnolia/definition/builder/simple/HiddenFieldDefinitionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.merkle.oss.magnolia.definition.builder.simple; | ||
|
||
import info.magnolia.ui.field.HiddenFieldDefinition; | ||
|
||
/** | ||
* builds a {@link HiddenFieldDefinition} | ||
* @see <a href="https://docs.magnolia-cms.com/product-docs/6.2/Developing/Templating/Dialog-definition/Field-definition/List-of-fields/Hidden-field.html">magnolia Docs - Hidden field </a> | ||
* @author Merkle DACH | ||
*/ | ||
public class HiddenFieldDefinitionBuilder<T> extends AbstractConfiguredFieldDefinitionBuilder<T, HiddenFieldDefinition<T>, HiddenFieldDefinitionBuilder<T>> { | ||
public HiddenFieldDefinition<T> build(final String name, final Class<T> type) { | ||
final HiddenFieldDefinition<T> definition = new HiddenFieldDefinition<>(); | ||
definition.setType(type); | ||
super.populate(definition, name); | ||
return definition; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...a/com/merkle/oss/magnolia/definition/builder/simple/HiddenFieldDefinitionBuilderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.merkle.oss.magnolia.definition.builder.simple; | ||
|
||
import com.merkle.oss.magnolia.definition.builder.AbstractFieldDefinitionBuilderTestCase; | ||
import info.magnolia.ui.field.HiddenFieldDefinition; | ||
import info.magnolia.ui.field.TextFieldDefinition; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class HiddenFieldDefinitionBuilderTest extends AbstractFieldDefinitionBuilderTestCase { | ||
@Test | ||
void testBuilder() { | ||
final HiddenFieldDefinition<Integer> definition = super.assertField(new HiddenFieldDefinitionBuilder<>(), (name, builder) -> builder.build(name, Integer.class), 42) | ||
.build("hidden", Integer.class); | ||
|
||
final HiddenFieldDefinition<String> emptyDefinition = new HiddenFieldDefinitionBuilder<String>().build("hidden", String.class); | ||
assertEquals(String.class, emptyDefinition.getType()); | ||
} | ||
} |