| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.core.api.cache; |
| 17 | |
|
| 18 | |
import org.apache.commons.lang.StringUtils; |
| 19 | |
import org.kuali.rice.core.api.CoreConstants; |
| 20 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 21 | |
import org.w3c.dom.Element; |
| 22 | |
|
| 23 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 24 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 25 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 26 | |
import javax.xml.bind.annotation.XmlElement; |
| 27 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 28 | |
import javax.xml.bind.annotation.XmlType; |
| 29 | |
import java.util.Collection; |
| 30 | |
|
| 31 | |
@XmlRootElement(name = CacheTarget.Constants.ROOT_ELEMENT_NAME) |
| 32 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 33 | |
@XmlType(name = CacheTarget.Constants.TYPE_NAME, propOrder = { |
| 34 | |
CacheTarget.Elements.CACHE, |
| 35 | |
CacheTarget.Elements.KEY, |
| 36 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 37 | |
}) |
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
public final class CacheTarget extends AbstractDataTransferObject { |
| 43 | |
|
| 44 | |
@XmlElement(name = Elements.CACHE, required = true) |
| 45 | |
private final String cache; |
| 46 | |
@XmlElement(name = Elements.KEY, required = false) |
| 47 | |
private final String key; |
| 48 | 0 | @SuppressWarnings("unused") |
| 49 | |
@XmlAnyElement |
| 50 | |
private final Collection<Element> _futureElements = null; |
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | 0 | private CacheTarget() { |
| 56 | 0 | this.cache = null; |
| 57 | 0 | this.key = null; |
| 58 | 0 | } |
| 59 | |
|
| 60 | 0 | private CacheTarget(String cache, String key) { |
| 61 | 0 | if (StringUtils.isBlank(cache)) { |
| 62 | 0 | throw new IllegalArgumentException("cache is blank or null"); |
| 63 | |
} |
| 64 | |
|
| 65 | 0 | this.cache = cache; |
| 66 | 0 | this.key = key; |
| 67 | 0 | } |
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
public static CacheTarget entireCache(String cache) { |
| 76 | 0 | return new CacheTarget(cache, null); |
| 77 | |
} |
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
public static CacheTarget singleEntry(String cache, String key) { |
| 87 | 0 | if (StringUtils.isBlank(key)) { |
| 88 | 0 | throw new IllegalArgumentException("a blank or null key does not target a single entry"); |
| 89 | |
} |
| 90 | |
|
| 91 | 0 | return new CacheTarget(cache, key); |
| 92 | |
} |
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
public boolean containsKey() { |
| 99 | 0 | return key != null; |
| 100 | |
} |
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
public String getCache() { |
| 107 | 0 | return cache; |
| 108 | |
} |
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
public String getKey() { |
| 115 | 0 | return key; |
| 116 | |
} |
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | 0 | static class Constants { |
| 122 | |
final static String ROOT_ELEMENT_NAME = "cacheTarget"; |
| 123 | |
final static String TYPE_NAME = "CacheTargetType"; |
| 124 | |
} |
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | 0 | static class Elements { |
| 131 | |
final static String CACHE = "cache"; |
| 132 | |
final static String KEY = "key"; |
| 133 | |
} |
| 134 | |
} |