From 4b65b12f50120c25fcb37add8e9c645b26ddf1d6 Mon Sep 17 00:00:00 2001 From: esmakula Date: Mon, 11 Dec 2017 12:38:51 +0200 Subject: [PATCH 1/2] tag history unique values --- .../main/java/net/anotheria/moskito/core/tag/Tag.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/moskito-core/src/main/java/net/anotheria/moskito/core/tag/Tag.java b/moskito-core/src/main/java/net/anotheria/moskito/core/tag/Tag.java index 6696d2adf..da0ebdb78 100644 --- a/moskito-core/src/main/java/net/anotheria/moskito/core/tag/Tag.java +++ b/moskito-core/src/main/java/net/anotheria/moskito/core/tag/Tag.java @@ -15,6 +15,10 @@ */ public class Tag implements Comparable { + /** + * String null value. + */ + private final static String NULL = "null"; /** * Tag name. */ @@ -68,7 +72,8 @@ public void addValue(String value) { lock.writeLock().lock(); try { - if (lastValues.peekLast() != null && lastValues.peekLast().equals(value)) { + final String lastValue = value != null ? value : NULL; + if (lastValues.contains(lastValue)) { return; } @@ -76,7 +81,7 @@ public void addValue(String value) { lastValues.removeFirst(); } - lastValues.add(value != null ? value : ""); + lastValues.add(lastValue); } finally { lock.writeLock().unlock(); } From 002c6d8887baef7432c7a184df9e056a4b5b2982 Mon Sep 17 00:00:00 2001 From: esmakula Date: Mon, 11 Dec 2017 12:50:52 +0200 Subject: [PATCH 2/2] tag history unique values --- .../src/main/java/net/anotheria/moskito/core/tag/Tag.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moskito-core/src/main/java/net/anotheria/moskito/core/tag/Tag.java b/moskito-core/src/main/java/net/anotheria/moskito/core/tag/Tag.java index da0ebdb78..1cc3aabb1 100644 --- a/moskito-core/src/main/java/net/anotheria/moskito/core/tag/Tag.java +++ b/moskito-core/src/main/java/net/anotheria/moskito/core/tag/Tag.java @@ -89,7 +89,7 @@ public void addValue(String value) { } @Override - public int compareTo(Tag o){ + public int compareTo(Tag o) { if (getType().equals(o.getType())) return getName().compareTo(o.getName()); return getType().compareTo(o.getType());