-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
951 additions
and
160 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
104 changes: 93 additions & 11 deletions
104
fx2j-parser/src/main/java/io/github/sheikah45/fx2j/parser/FxmlAttribute.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 |
---|---|---|
@@ -1,24 +1,106 @@ | ||
package io.github.sheikah45.fx2j.parser; | ||
|
||
import io.github.sheikah45.fx2j.parser.utils.StringUtils; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Objects; | ||
|
||
public sealed interface FxmlAttribute { | ||
sealed interface Property extends FxmlAttribute { | ||
record Instance(String property, Value value) implements Property { | ||
public Instance { | ||
if (StringUtils.isNullOrBlank(property)) { | ||
throw new IllegalArgumentException("property cannot be blank or null"); | ||
} | ||
Objects.requireNonNull(value, "value cannot be null"); | ||
} | ||
} | ||
record Static(String className, String property, Value value) implements Property { | ||
public Static { | ||
if (StringUtils.isNullOrBlank(className)) { | ||
throw new IllegalArgumentException("className cannot be blank or null"); | ||
} | ||
if (StringUtils.isNullOrBlank(property)) { | ||
throw new IllegalArgumentException("property cannot be blank or null"); | ||
} | ||
Objects.requireNonNull(value, "value cannot be null"); | ||
} | ||
} | ||
|
||
sealed interface Value {} | ||
record Instance(String property, Value value) implements Property {} | ||
record Static(String className, String property, Value value) implements Property {} | ||
record Literal(String value) implements Value {} | ||
record Location(Path location) implements Value {} | ||
record Resource(String resource) implements Value {} | ||
record Reference(String variable) implements Value {} | ||
record BindExpression(String expression) implements Value {} | ||
|
||
record Empty() implements Value {} | ||
record Literal(String value) implements Value { | ||
public Literal { | ||
if (StringUtils.isNullOrBlank(value)) { | ||
throw new IllegalArgumentException("value cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Location(Path location) implements Value { | ||
public Location { | ||
Objects.requireNonNull(location, "location cannot be null"); | ||
} | ||
} | ||
record Resource(String value) implements Value { | ||
public Resource { | ||
if (StringUtils.isNullOrBlank(value)) { | ||
throw new IllegalArgumentException("value cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Reference(String value) implements Value { | ||
public Reference { | ||
if (StringUtils.isNullOrBlank(value)) { | ||
throw new IllegalArgumentException("value cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Expression(String value) implements Value { | ||
public Expression { | ||
if (StringUtils.isNullOrBlank(value)) { | ||
throw new IllegalArgumentException("value cannot be blank or null"); | ||
} | ||
} | ||
} | ||
} | ||
record Id(String value) implements FxmlAttribute { | ||
public Id { | ||
if (StringUtils.isNullOrBlank(value)) { | ||
throw new IllegalArgumentException("id cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Controller(String className) implements FxmlAttribute { | ||
public Controller { | ||
if (StringUtils.isNullOrBlank(className)) { | ||
throw new IllegalArgumentException("className cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Controller(String className) implements FxmlAttribute {} | ||
record EventHandler(String eventName, Value value) implements FxmlAttribute { | ||
sealed interface Value {} | ||
|
||
record Script(String value) implements Value {} | ||
record Method(String method) implements Value {} | ||
record Reference(String reference) implements Value {} | ||
record Script(String value) implements Value { | ||
public Script { | ||
if (StringUtils.isNullOrBlank(value)) { | ||
throw new IllegalArgumentException("value cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Method(String method) implements Value { | ||
public Method { | ||
if (StringUtils.isNullOrBlank(method)) { | ||
throw new IllegalArgumentException("method cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Reference(String reference) implements Value { | ||
public Reference { | ||
if (StringUtils.isNullOrBlank(reference)) { | ||
throw new IllegalArgumentException("reference cannot be blank or null"); | ||
} | ||
} | ||
} | ||
} | ||
} |
10 changes: 6 additions & 4 deletions
10
fx2j-parser/src/main/java/io/github/sheikah45/fx2j/parser/FxmlComponents.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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package io.github.sheikah45.fx2j.parser; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public record FxmlComponents(FxmlNode rootNode, Map<String, Set<String>> processingInstructions) { | ||
public record FxmlComponents(FxmlNode rootNode, List<FxmlProcessingInstruction> processingInstructions) { | ||
public FxmlComponents { | ||
processingInstructions = Map.copyOf(processingInstructions); | ||
Objects.requireNonNull(rootNode, "rootNode cannot be null"); | ||
Objects.requireNonNull(processingInstructions, "processingInstructions cannot be null"); | ||
processingInstructions = List.copyOf(processingInstructions); | ||
} | ||
} |
103 changes: 91 additions & 12 deletions
103
fx2j-parser/src/main/java/io/github/sheikah45/fx2j/parser/FxmlElement.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 |
---|---|---|
@@ -1,23 +1,102 @@ | ||
package io.github.sheikah45.fx2j.parser; | ||
|
||
import io.github.sheikah45.fx2j.parser.utils.StringUtils; | ||
|
||
import java.nio.charset.Charset; | ||
import java.nio.file.Path; | ||
import java.util.Objects; | ||
|
||
public sealed interface FxmlElement { | ||
sealed interface Instance extends FxmlElement { | ||
String id(); | ||
sealed interface Declaration extends FxmlElement { | ||
record Class(String className) implements Declaration { | ||
public Class { | ||
if (StringUtils.isNullOrBlank(className)) { | ||
throw new IllegalArgumentException("className cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Value(String className, String value) implements Declaration { | ||
public Value { | ||
if (StringUtils.isNullOrBlank(className)) { | ||
throw new IllegalArgumentException("className cannot be blank or null"); | ||
} | ||
|
||
if (StringUtils.isNullOrBlank(value)) { | ||
throw new IllegalArgumentException("value cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Constant(String className, String value) implements Declaration { | ||
public Constant { | ||
if (StringUtils.isNullOrBlank(className)) { | ||
throw new IllegalArgumentException("className cannot be blank or null"); | ||
} | ||
|
||
if (StringUtils.isNullOrBlank(value)) { | ||
throw new IllegalArgumentException("value cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Factory(String factoryClassName, String factoryMethod) implements Declaration { | ||
public Factory { | ||
if (StringUtils.isNullOrBlank(factoryClassName)) { | ||
throw new IllegalArgumentException("factoryClassName cannot be blank or null"); | ||
} | ||
|
||
if (StringUtils.isNullOrBlank(factoryMethod)) { | ||
throw new IllegalArgumentException("factoryMethod cannot be blank or null"); | ||
} | ||
} | ||
} | ||
} | ||
sealed interface Property extends FxmlElement { | ||
record Instance(String property) implements Property { | ||
public Instance { | ||
if (StringUtils.isNullOrBlank(property)) { | ||
throw new IllegalArgumentException("property cannot be blank or null"); | ||
} | ||
} | ||
} | ||
|
||
record Simple(String id, String className) implements Instance {} | ||
record Value(String id, String className, String value) implements Instance {} | ||
record Constant(String id, String className, String constant) implements Instance {} | ||
record Factory(String id, String factoryClassName, String factoryMethod) implements Instance {} | ||
record Static(String className, String property) implements Property { | ||
public Static { | ||
if (StringUtils.isNullOrBlank(className)) { | ||
throw new IllegalArgumentException("className cannot be blank or null"); | ||
} | ||
if (StringUtils.isNullOrBlank(property)) { | ||
throw new IllegalArgumentException("property cannot be blank or null"); | ||
} | ||
} | ||
} | ||
} | ||
record Include(Path source, Path resources, Charset charset) implements FxmlElement { | ||
public Include { | ||
Objects.requireNonNull(source, "source cannot be null"); | ||
Objects.requireNonNull(charset, "charset cannot be null"); | ||
} | ||
} | ||
record Copy(String source) implements FxmlElement { | ||
public Copy { | ||
if (StringUtils.isNullOrBlank(source)) { | ||
throw new IllegalArgumentException("source cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Reference(String source) implements FxmlElement { | ||
public Reference { | ||
if (StringUtils.isNullOrBlank(source)) { | ||
throw new IllegalArgumentException("source cannot be blank or null"); | ||
} | ||
} | ||
} | ||
record Include(String id, Path source, Path resources, Charset charset) implements FxmlElement {} | ||
record Copy(String id, String source) implements FxmlElement {} | ||
record Reference(String id, String source) implements FxmlElement {} | ||
record Root(String id, String type) implements FxmlElement {} | ||
record Define() implements FxmlElement {} | ||
record Script() implements FxmlElement {} | ||
record Property(String property) implements FxmlElement {} | ||
record StaticProperty(String className, String property) implements FxmlElement {} | ||
record Root(String type) implements FxmlElement { | ||
public Root { | ||
if (StringUtils.isNullOrBlank(type)) { | ||
throw new IllegalArgumentException("type cannot be blank or null"); | ||
} | ||
} | ||
} | ||
|
||
} |
13 changes: 12 additions & 1 deletion
13
fx2j-parser/src/main/java/io/github/sheikah45/fx2j/parser/FxmlNode.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 |
---|---|---|
@@ -1,9 +1,20 @@ | ||
package io.github.sheikah45.fx2j.parser; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
|
||
public record FxmlNode(FxmlElement element, | ||
List<FxmlAttribute> attributes, | ||
String innerText, | ||
List<FxmlNode> children) {} | ||
List<FxmlNode> children) { | ||
|
||
public FxmlNode { | ||
Objects.requireNonNull(element, "element cannot be null"); | ||
Objects.requireNonNull(attributes, "attributes cannot be null"); | ||
Objects.requireNonNull(innerText, "innerText cannot be null"); | ||
Objects.requireNonNull(children, "children cannot be null"); | ||
attributes = List.copyOf(attributes); | ||
children = List.copyOf(children); | ||
} | ||
} |
Oops, something went wrong.