diff --git a/src/main/java/io/jare/cached/CdBase.java b/src/main/java/io/jare/cached/CdBase.java index edc8291..3df08d6 100644 --- a/src/main/java/io/jare/cached/CdBase.java +++ b/src/main/java/io/jare/cached/CdBase.java @@ -22,6 +22,8 @@ */ package io.jare.cached; +import com.google.common.collect.Iterables; +import com.google.common.collect.Iterators; import com.jcabi.aspects.Cacheable; import io.jare.model.Base; import io.jare.model.Domain; @@ -60,12 +62,18 @@ public User user(final String name) { @Override @Cacheable(forever = true) public Iterator domain(final String name) { - return this.origin.domain(name); + return Iterators.transform( + this.origin.domain(name), + CdDomain::new + ); } @Override @Cacheable(unit = TimeUnit.HOURS, lifetime = 1) public Iterable all() { - return this.origin.all(); + return Iterables.transform( + this.origin.all(), + CdDomain::new + ); } } diff --git a/src/main/java/io/jare/cached/CdDomain.java b/src/main/java/io/jare/cached/CdDomain.java new file mode 100644 index 0000000..b2b47a1 --- /dev/null +++ b/src/main/java/io/jare/cached/CdDomain.java @@ -0,0 +1,67 @@ +/** + * The MIT License (MIT) + * + * Copyright (c) 2016 jare.io + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: the above copyright notice and this + * permission notice shall be included in all copies or substantial + * portions of the Software. The software is provided "as is", without + * warranty of any kind, express or implied, including but not limited to + * the warranties of merchantability, fitness for a particular purpose + * and non-infringement. In no event shall the authors or copyright + * holders be liable for any claim, damages or other liability, whether + * in an action of contract, tort or otherwise, arising from, out of or + * in connection with the software or the use or other dealings in the + * software. + */ +package io.jare.cached; + +import com.jcabi.aspects.Cacheable; +import io.jare.model.Domain; +import java.io.IOException; + +/** + * Cached Domain. + * + * @author Yegor Bugayenko (yegor@teamed.io) + * @version $Id$ + * @since 1.0 + */ +public final class CdDomain implements Domain { + + /** + * Original. + */ + private final transient Domain origin; + + /** + * Ctor. + * @param domain Original + */ + public CdDomain(final Domain domain) { + this.origin = domain; + } + + @Override + @Cacheable(forever = true) + public String owner() throws IOException { + return this.origin.owner(); + } + + @Override + @Cacheable(forever = true) + public String name() throws IOException { + return this.origin.name(); + } + + @Override + public void delete() throws IOException { + this.origin.delete(); + } +} diff --git a/web.iml b/web.iml index 050e6c4..3fd9fa2 100644 --- a/web.iml +++ b/web.iml @@ -43,14 +43,14 @@ - + + -