Skip to content

Commit

Permalink
Added constructors to mappers.
Browse files Browse the repository at this point in the history
  • Loading branch information
ygimenez committed Oct 2, 2024
1 parent c8d962f commit 6169161
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/main/java/com/github/ygimenez/model/EmojiMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,24 @@
* Effectively a {@link HashMap} with {@link Emoji} key and {@link Page} values, with built-in conversion.
*/
public class EmojiMapping<V> implements Mapping<V> {
private final Map<ButtonId<?>, V> mapping = new LinkedHashMap<>();
private final Map<ButtonId<?>, V> mapping;
private final IdCursor<Emoji> cursor = new IdCursor<>();

/**
* Creates a new instance, with default map implementation.
*/
public EmojiMapping() {
this(new LinkedHashMap<>());
}

/**
* Creates a new instance, using supplied map.
* @param mapping The map to be used internally to store mappings.
*/
public EmojiMapping(Map<ButtonId<?>, V> mapping) {
this.mapping = mapping;
}

public Map<ButtonId<?>, V> toMap() {
return mapping;
}
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/com/github/ygimenez/model/TextMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@
* Effectively a {@link HashMap} with {@link String} key and {@link Page} values, with built-in conversion.
*/
public class TextMapping<V> implements Mapping<V> {
private final Map<ButtonId<?>, V> mapping = new LinkedHashMap<>();
private final Map<ButtonId<?>, V> mapping;
private final IdCursor<String> cursor = new IdCursor<>();

/**
* Creates a new instance, with default map implementation.
*/
public TextMapping() {
this(new LinkedHashMap<>());
}

/**
* Creates a new instance, using supplied map.
* @param mapping The map to be used internally to store mappings.
*/
public TextMapping(Map<ButtonId<?>, V> mapping) {
this.mapping = mapping;
}

public Map<ButtonId<?>, V> toMap() {
return mapping;
}
Expand Down

0 comments on commit 6169161

Please sign in to comment.