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
package se.labs.cache; | |
/** | |
* | |
* @author ne | |
* | |
* @param <T> The item to cache | |
*/ | |
public interface ItemCache<T> { |
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
package se.labs.cache; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
/** | |
* | |
* @author ne | |
* | |
*/ |
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
package se.labs.cache; | |
/** | |
* @author ne | |
* | |
*/ | |
public interface ItemCacheLoader<T> { | |
/** |
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
package se.labs.cache.tests; | |
import static org.hamcrest.core.Is.is; | |
import static org.junit.Assert.assertThat; | |
import static org.mockito.Mockito.mock; | |
import static org.mockito.Mockito.when; | |
import org.junit.Test; | |
import se.labs.cache.ItemCacheImpl; |
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
package se.labs.cache; | |
/** | |
* | |
* @author ne | |
* | |
*/ | |
public class ItemCacheFactory { | |
/** | |
* |
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
package se.labs.app; | |
import java.util.Properties; | |
import se.labs.cache.ItemCache; | |
import se.labs.cache.ItemCacheFactory; | |
import se.labs.cache.loaders.PropertyCacheLoader; | |
public class AppProperties { |
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
/* | |
Property extract function from http://cjohansen.no/talks/2012/javazone/ | |
*/ | |
function prop(name) { | |
return function (object) { | |
return object[name]; | |
}; | |
} |
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
var persons = [ | |
{ name : 'Kalle', age : 20 }, | |
{ name : 'Line', age : 24 }, | |
{ name : 'Greta', age : 50 } | |
]; |
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
var names = persons.map(function(person) { | |
return person.name; | |
}); | |
// => ['Kalle', 'Line', 'Greta']; |
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
var names = persons.map(function(person) { | |
return person.name; | |
}); | |
// => ['Kalle', 'Line', 'Greta']; |