| 353 | * @see BasicElement#getParent() |
| 354 | */ |
| 355 | public U getBaseUnit(ChronoElement<?> element) { |
| 356 | |
| 357 | if (element == null) { |
| 358 | throw new NullPointerException("Missing element."); |
| 359 | } |
| 360 | |
| 361 | U baseUnit = this.baseUnits.get(element); |
| 362 | |
| 363 | if ( |
| 364 | (baseUnit == null) |
| 365 | && (element instanceof BasicElement) |
| 366 | ) { |
| 367 | ChronoElement<?> parent = ((BasicElement) element).getParent(); |
| 368 | baseUnit = this.baseUnits.get(parent); |
| 369 | } |
| 370 | |
| 371 | if (baseUnit == null) { |
| 372 | throw new ChronoException( |
| 373 | "Base unit not found for: " + element.name()); |
| 374 | } |
| 375 | |
| 376 | return baseUnit; |
| 377 | |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * <p>Compares time units by ascending precision (that is descending length). </p> |