Skip to content

Commit

Permalink
Normalize EOL to unix LF
Browse files Browse the repository at this point in the history
  • Loading branch information
dubreuia committed Oct 6, 2017
1 parent 95e144f commit 257c1c0
Show file tree
Hide file tree
Showing 52 changed files with 4,967 additions and 4,964 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
@@ -0,0 +1,3 @@
# IT-1055 Set default behaviour, in case users don't have core.autocrlf set.
* text=auto

52 changes: 26 additions & 26 deletions core/pom.xml
@@ -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>
64 changes: 32 additions & 32 deletions core/src/main/java/org/modelmap/core/FieldId.java
@@ -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);
}
}
76 changes: 38 additions & 38 deletions core/src/main/java/org/modelmap/core/FieldInfo.java
@@ -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);

}
160 changes: 80 additions & 80 deletions core/src/main/java/org/modelmap/core/FieldModel.java
@@ -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);
}
}
20 changes: 10 additions & 10 deletions core/src/main/java/org/modelmap/core/Path.java
@@ -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 {
}

0 comments on commit 257c1c0

Please sign in to comment.