MCPcopy Create free account
hub / github.com/MenoData/Time4J / addParsedItem

Method addParsedItem

base/src/main/java/net/time4j/Duration.java:3851–3877  ·  view source on GitHub ↗
(
        ChronoUnit unit,
        ChronoUnit last, // optional
        long amount,
        String period,
        int index,
        List<Item<U>> items
    )

Source from the content-addressed store, hash-verified

3849 }
3850
3851 private static <U extends ChronoUnit> ChronoUnit addParsedItem(
3852 ChronoUnit unit,
3853 ChronoUnit last, // optional
3854 long amount,
3855 String period,
3856 int index,
3857 List<Item<U>> items
3858 ) throws ParseException {
3859
3860 if (
3861 (last == null)
3862 || (Double.compare(unit.getLength(), last.getLength()) < 0)
3863 ) {
3864 if (amount != 0) {
3865 U reified = cast(unit);
3866 items.add(Item.of(amount, reified));
3867 }
3868 return unit;
3869 } else if (Double.compare(unit.getLength(), last.getLength()) == 0) {
3870 throw new ParseException(
3871 "Duplicate unit items: " + period, index);
3872 } else {
3873 throw new ParseException(
3874 "Wrong order of unit items: " + period, index);
3875 }
3876
3877 }
3878
3879 private static long parseAmount(
3880 String period,

Callers 1

parseMethod · 0.95

Calls 5

castMethod · 0.95
ofMethod · 0.95
compareMethod · 0.65
getLengthMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected