1111package javax .money ;
1212
1313import java .io .Serializable ;
14- import java .time .Instant ;
15- import java .time .temporal .ChronoField ;
16- import java .time .temporal .TemporalAccessor ;
1714import java .util .HashMap ;
1815import java .util .Map ;
1916import java .util .Objects ;
@@ -34,12 +31,8 @@ public abstract class AbstractContext implements Serializable {
3431 /**
3532 * Key for storing the target providers to be queried
3633 */
37- public static final String KEY_PROVIDER = "provider" ;
34+ protected static final String KEY_PROVIDER = "provider" ;
3835
39- /**
40- * Key name for the timestamp attribute.
41- */
42- public static final String KEY_TIMESTAMP = "timestamp" ;
4336
4437 /**
4538 * The data map containing all values.
@@ -175,43 +168,6 @@ public String getProviderName() {
175168 return getText (KEY_PROVIDER );
176169 }
177170
178- /**
179- * Get the current target timestamp of the query in UTC milliseconds. If not set it tries to of an
180- * UTC timestamp from #getTimestamp(). This allows to select historical roundings that were valid in the
181- * past. Its implementation specific, to what extend historical roundings are available. By default if this
182- * property is not set always current {@link javax.money.MonetaryRounding} instances are provided.
183- *
184- * @return the timestamp in millis, or null.
185- */
186- public Long getTimestampMillis () {
187- Long value = get (KEY_TIMESTAMP , Long .class );
188- if (Objects .isNull (value )) {
189- TemporalAccessor acc = getTimestamp ();
190- if (Objects .nonNull (acc )) {
191- return (acc .getLong (ChronoField .INSTANT_SECONDS ) * 1000L ) + acc .getLong (ChronoField .MILLI_OF_SECOND );
192- }
193- }
194- return value ;
195- }
196-
197- /**
198- * Get the current target timestamp of the query. If not set it tries to of an Instant from
199- * #getTimestampMillis(). This allows to select historical roundings that were valid in the
200- * past. Its implementation specific, to what extend historical roundings are available. By default if this
201- * property is not set always current {@link javax.money.MonetaryRounding} instances are provided.
202- *
203- * @return the current timestamp, or null.
204- */
205- public TemporalAccessor getTimestamp () {
206- TemporalAccessor acc = get (KEY_TIMESTAMP , TemporalAccessor .class );
207- if (Objects .isNull (acc )) {
208- Long value = get (KEY_TIMESTAMP , Long .class );
209- if (Objects .nonNull (value )) {
210- acc = Instant .ofEpochMilli (value );
211- }
212- }
213- return acc ;
214- }
215171
216172 /**
217173 * Checks if the current instance has no attributes set. This is often the cases, when used in default cases.
@@ -232,19 +188,6 @@ public int hashCode() {
232188 return Objects .hash (data );
233189 }
234190
235- /**
236- * Access all the key/values present, filtered by the values that are assignable to the given type.
237- *
238- * @param type the value type, not null.
239- * @return return all key/values with values assignable to a given value type.
240- */
241- public <T > Map <String , T > getValues (Class <T > type ) {
242- Map <String , T > result = new HashMap <>();
243- data .entrySet ().stream ().filter (en -> type .isAssignableFrom (en .getValue ().getClass ())).forEach (
244- en -> result .put (en .getKey (), type .cast (en .getValue ())));
245- return result ;
246- }
247-
248191 /*
249192 * (non-Javadoc)
250193 *
0 commit comments