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
52 changed files
with
4,967 additions
and
4,964 deletions.
There are no files selected for viewing
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,3 @@ | ||
# IT-1055 Set default behaviour, in case users don't have core.autocrlf set. | ||
* text=auto | ||
|
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,27 +1,27 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.modelmap</groupId> | ||
<artifactId>modelmap-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>modelmap-core</artifactId> | ||
<name>ModelMap Core</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.modelmap</groupId> | ||
<artifactId>modelmap-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>modelmap-core</artifactId> | ||
<name>ModelMap Core</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
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,32 +1,32 @@ | ||
package org.modelmap.core; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Id representing a value of the {@code FieldModel} | ||
*/ | ||
public interface FieldId { | ||
|
||
/** | ||
* @return the field unique identifier | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* @return the field position, when referencing an element in a {@code Collection} | ||
*/ | ||
int position(); | ||
|
||
/** | ||
* @return optionnal tags used to decorate this field | ||
*/ | ||
List<TagId> tags(); | ||
|
||
/** | ||
* @param tag the tag to check | ||
* @return <code>true</code> if this field is tagged by <code>tag</code> | ||
*/ | ||
default boolean hasTag(TagId tag) { | ||
return tags().contains(tag); | ||
} | ||
} | ||
package org.modelmap.core; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Id representing a value of the {@code FieldModel} | ||
*/ | ||
public interface FieldId { | ||
|
||
/** | ||
* @return the field unique identifier | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* @return the field position, when referencing an element in a {@code Collection} | ||
*/ | ||
int position(); | ||
|
||
/** | ||
* @return optionnal tags used to decorate this field | ||
*/ | ||
List<TagId> tags(); | ||
|
||
/** | ||
* @param tag the tag to check | ||
* @return <code>true</code> if this field is tagged by <code>tag</code> | ||
*/ | ||
default boolean hasTag(TagId tag) { | ||
return tags().contains(tag); | ||
} | ||
} |
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,38 +1,38 @@ | ||
package org.modelmap.core; | ||
|
||
/** | ||
* Properties of a {@code FieldId}, generated from the model java bean | ||
*/ | ||
public interface FieldInfo { | ||
|
||
/** | ||
* @return the referenced {@code FieldId} | ||
*/ | ||
FieldId id(); | ||
|
||
/** | ||
* @return the other {@code FieldId} mapped on the same property | ||
*/ | ||
FieldId[] siblings(); | ||
|
||
/** | ||
* @return the human readable {@code FieldId} | ||
*/ | ||
String readable(); | ||
|
||
/** | ||
* @return the {@code FieldId} type | ||
*/ | ||
Class<?> type(); | ||
|
||
/** | ||
* @return the {@code FieldId} type parameters | ||
*/ | ||
Class<?>[] genericTypes(); | ||
|
||
/** | ||
* @return the {@code FieldId} with different readable | ||
*/ | ||
FieldInfo as(String readable); | ||
|
||
} | ||
package org.modelmap.core; | ||
|
||
/** | ||
* Properties of a {@code FieldId}, generated from the model java bean | ||
*/ | ||
public interface FieldInfo { | ||
|
||
/** | ||
* @return the referenced {@code FieldId} | ||
*/ | ||
FieldId id(); | ||
|
||
/** | ||
* @return the other {@code FieldId} mapped on the same property | ||
*/ | ||
FieldId[] siblings(); | ||
|
||
/** | ||
* @return the human readable {@code FieldId} | ||
*/ | ||
String readable(); | ||
|
||
/** | ||
* @return the {@code FieldId} type | ||
*/ | ||
Class<?> type(); | ||
|
||
/** | ||
* @return the {@code FieldId} type parameters | ||
*/ | ||
Class<?>[] genericTypes(); | ||
|
||
/** | ||
* @return the {@code FieldId} with different readable | ||
*/ | ||
FieldInfo as(String readable); | ||
|
||
} |
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,80 +1,80 @@ | ||
package org.modelmap.core; | ||
|
||
import static java.util.stream.Collectors.toList; | ||
|
||
import java.util.*; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* An model that maps {@code FieldId} to values. Each {@code FieldId} can map to at most one value. | ||
*/ | ||
public interface FieldModel extends Iterable<Map.Entry<FieldId, Object>> { | ||
|
||
/** | ||
* @param fieldId the {@code FieldId} to read | ||
* @return the the {@code FieldId} value | ||
*/ | ||
<T> T get(FieldId fieldId); | ||
|
||
/** | ||
* @param fieldId the {@code FieldId} to update | ||
* @param value the new {@code FieldId} value | ||
*/ | ||
<T> void set(FieldId fieldId, T value); | ||
|
||
/** | ||
* return a sequential {@code Stream} with all key-value pairs | ||
*/ | ||
Stream<Map.Entry<FieldId, Object>> stream(); | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
Spliterator<Map.Entry<FieldId, Object>> spliterator(); | ||
|
||
/** | ||
* return a parallel {@code Stream} with all key-value pairs | ||
*/ | ||
Stream<Map.Entry<FieldId, Object>> parallelStream(); | ||
|
||
/** | ||
* @return the {@code FieldInfo} FieldInfo for all this model {@code FieldId} | ||
*/ | ||
List<FieldInfo> getFieldInfos(); | ||
|
||
/** | ||
* @return all {@code FieldId}, with a not-null value | ||
*/ | ||
default List<FieldId> getFieldIds() { | ||
return getFieldInfos().stream().map(FieldInfo::id).collect(toList()); | ||
} | ||
|
||
/** | ||
* Copy all the values for the {@code FieldModel} <code>source</code> | ||
* | ||
* @param source the source field model | ||
*/ | ||
default void setAll(FieldModel source) { | ||
getFieldInfos().stream().filter(info -> source.get(info.id()) != null) | ||
.forEach(info -> set(info.id(), source.get(info.id()))); | ||
} | ||
|
||
/** | ||
* For all the {@code FieldId}, set their value to <code>null</code> | ||
*/ | ||
default void clear() { | ||
getFieldInfos().stream().filter(info -> get(info.id()) != null).forEach(info -> set(info.id(), null)); | ||
} | ||
|
||
/** | ||
* For all the {@code FieldId} tagged with the specified {@code TagId}, set their value to <code>null</code> | ||
*/ | ||
default void clear(TagId tag) { | ||
getFieldInfos().stream().filter(info -> info.id().hasTag(tag) && get(info.id()) != null) | ||
.forEach(info -> set(info.id(), null)); | ||
} | ||
|
||
default FieldInfo info(FieldId id) { | ||
return getFieldInfos().stream().filter(info -> info.id() == id).findFirst().orElse(null); | ||
} | ||
} | ||
package org.modelmap.core; | ||
|
||
import static java.util.stream.Collectors.toList; | ||
|
||
import java.util.*; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* An model that maps {@code FieldId} to values. Each {@code FieldId} can map to at most one value. | ||
*/ | ||
public interface FieldModel extends Iterable<Map.Entry<FieldId, Object>> { | ||
|
||
/** | ||
* @param fieldId the {@code FieldId} to read | ||
* @return the the {@code FieldId} value | ||
*/ | ||
<T> T get(FieldId fieldId); | ||
|
||
/** | ||
* @param fieldId the {@code FieldId} to update | ||
* @param value the new {@code FieldId} value | ||
*/ | ||
<T> void set(FieldId fieldId, T value); | ||
|
||
/** | ||
* return a sequential {@code Stream} with all key-value pairs | ||
*/ | ||
Stream<Map.Entry<FieldId, Object>> stream(); | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
Spliterator<Map.Entry<FieldId, Object>> spliterator(); | ||
|
||
/** | ||
* return a parallel {@code Stream} with all key-value pairs | ||
*/ | ||
Stream<Map.Entry<FieldId, Object>> parallelStream(); | ||
|
||
/** | ||
* @return the {@code FieldInfo} FieldInfo for all this model {@code FieldId} | ||
*/ | ||
List<FieldInfo> getFieldInfos(); | ||
|
||
/** | ||
* @return all {@code FieldId}, with a not-null value | ||
*/ | ||
default List<FieldId> getFieldIds() { | ||
return getFieldInfos().stream().map(FieldInfo::id).collect(toList()); | ||
} | ||
|
||
/** | ||
* Copy all the values for the {@code FieldModel} <code>source</code> | ||
* | ||
* @param source the source field model | ||
*/ | ||
default void setAll(FieldModel source) { | ||
getFieldInfos().stream().filter(info -> source.get(info.id()) != null) | ||
.forEach(info -> set(info.id(), source.get(info.id()))); | ||
} | ||
|
||
/** | ||
* For all the {@code FieldId}, set their value to <code>null</code> | ||
*/ | ||
default void clear() { | ||
getFieldInfos().stream().filter(info -> get(info.id()) != null).forEach(info -> set(info.id(), null)); | ||
} | ||
|
||
/** | ||
* For all the {@code FieldId} tagged with the specified {@code TagId}, set their value to <code>null</code> | ||
*/ | ||
default void clear(TagId tag) { | ||
getFieldInfos().stream().filter(info -> info.id().hasTag(tag) && get(info.id()) != null) | ||
.forEach(info -> set(info.id(), null)); | ||
} | ||
|
||
default FieldInfo info(FieldId id) { | ||
return getFieldInfos().stream().filter(info -> info.id() == id).findFirst().orElse(null); | ||
} | ||
} |
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,11 +1,11 @@ | ||
package org.modelmap.core; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* Annotates an annotation used to annotate a bean property (attribute, getter or setter) with a {@code FieldId} | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.ANNOTATION_TYPE) | ||
public @interface Path { | ||
package org.modelmap.core; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* Annotates an annotation used to annotate a bean property (attribute, getter or setter) with a {@code FieldId} | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.ANNOTATION_TYPE) | ||
public @interface Path { | ||
} |
Oops, something went wrong.