-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ServiceMap (basically a key/value map interface)
- Loading branch information
Showing
6 changed files
with
80 additions
and
0 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
11 changes: 11 additions & 0 deletions
11
data-service-base/src/main/java/org/fugerit/java/dsb/attributes/ServiceMap.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.fugerit.java.dsb.attributes; | ||
|
||
public interface ServiceMap<K,V> { | ||
|
||
V get(K key); | ||
|
||
void set(K key, V value); | ||
|
||
void remove(K key); | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
data-service-base/src/main/java/org/fugerit/java/dsb/attributes/SimpleServiceMap.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.fugerit.java.dsb.attributes; | ||
|
||
public interface SimpleServiceMap extends ServiceMap<String, String> { | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
data-service-base/src/main/java/org/fugerit/java/dsb/attributes/impl/ServiceMapDefault.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.fugerit.java.dsb.attributes.impl; | ||
|
||
import org.fugerit.java.dsb.attributes.ServiceMap; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ServiceMapDefault<K, V> implements ServiceMap<K, V> { | ||
|
||
private Map<K, V> map; | ||
public ServiceMapDefault() { | ||
this.map = new HashMap<K, V>(); | ||
} | ||
|
||
@Override | ||
public V get(K key) { | ||
return this.map.get( key ); | ||
} | ||
|
||
@Override | ||
public void set(K key, V value ) { | ||
this.map.put( key, value ); | ||
} | ||
|
||
@Override | ||
public void remove(K key) { | ||
this.map.remove( key ); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...vice-base/src/main/java/org/fugerit/java/dsb/attributes/impl/SimpleServiceMapDefault.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.fugerit.java.dsb.attributes.impl; | ||
|
||
public class SimpleServiceMapDefault extends ServiceMapDefault<String, String> implements org.fugerit.java.dsb.attributes.SimpleServiceMap { | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...e-base/src/test/java/test/org/fugerit/java/dsb/attributes/impl/ServiceMapDefaultTest.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package test.org.fugerit.java.dsb.attributes.impl; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.fugerit.java.dsb.attributes.SimpleServiceMap; | ||
import org.fugerit.java.dsb.attributes.impl.SimpleServiceMapDefault; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
@Slf4j | ||
public class ServiceMapDefaultTest { | ||
|
||
@Test | ||
public void testMapSimple() { | ||
String key = "testKey"; | ||
String value = "testValue"; | ||
SimpleServiceMap map = new SimpleServiceMapDefault(); | ||
map.set( key, value ); | ||
Assert.assertEquals( value, map.get( key ) ); | ||
map.remove( key ); | ||
Assert.assertNull( map.get( key ) ); | ||
log.info( "test key:{}, value:{} ok", key, value ); | ||
} | ||
|
||
} |