Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jul 4, 2020
1 parent f16f5d7 commit 696c62c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Expand Up @@ -29,13 +29,13 @@ public class DefaultZoneRulesProvider extends ZoneRulesProvider {
private final Map<String, ZoneRules> zoneRulesMap;

public DefaultZoneRulesProvider() {
this(new TimeZoneLoader(DEFAULT_RESOURCE_PREFIX));
this(new TimeZoneLoader(DEFAULT_RESOURCE_PREFIX), TimeZoneRegistry.ZONE_IDS);
}

public DefaultZoneRulesProvider(TimeZoneLoader timeZoneLoader) {
public DefaultZoneRulesProvider(TimeZoneLoader timeZoneLoader, Map<String, String> zoneIdMap) {
this.zoneLoader = timeZoneLoader;
for (String id : zoneLoader.getAvailableIDs()) {
TimeZoneRegistry.ZONE_IDS.put("ical4j~" + UUID.randomUUID().toString(), id);
zoneIdMap.put("ical4j~" + UUID.randomUUID().toString(), id);
}
this.zoneRulesMap = new ConcurrentHashMap<>();
}
Expand Down
Expand Up @@ -134,6 +134,7 @@ private int getTemporalField(T date, TemporalField field) {
}
}

@SuppressWarnings("unchecked")
T withTemporalField(T date, TemporalField field, int value) {
if (date.isSupported(field)) {
return (T) date.with(field, value);
Expand Down
Expand Up @@ -8,7 +8,7 @@ class DefaultZoneRulesProviderTest extends Specification {

def 'asset new instance available ids'() {
given: 'a zone rules provider'
DefaultZoneRulesProvider provider = []
DefaultZoneRulesProvider provider = [new TimeZoneLoader(TimeZoneRegistryImpl.DEFAULT_RESOURCE_PREFIX), new HashMap<String, String>()]

when: 'requesting available ids'
def availableIds = provider.provideZoneIds()
Expand Down

0 comments on commit 696c62c

Please sign in to comment.