| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| FactorChangeEvent |
|
| 1.0;1 |
| 1 | package com.timjohnstondev.unitconverter.view.listener; | |
| 2 | ||
| 3 | import java.math.BigDecimal; | |
| 4 | import java.util.EventObject; | |
| 5 | ||
| 6 | /** | |
| 7 | * {@code FactorChangeEvent} is used to notify interested parties that factor has changed. | |
| 8 | */ | |
| 9 | public class FactorChangeEvent extends EventObject | |
| 10 | { | |
| 11 | /** | |
| 12 | * Tells the listeners to clear the factor displays | |
| 13 | */ | |
| 14 | public static final int CLEAR_FACTOR_ACTION = 1; | |
| 15 | private String conversion; | |
| 16 | private int action; | |
| 17 | 0 | private BigDecimal molecularWeight = BigDecimal.ONE; |
| 18 | ||
| 19 | /** | |
| 20 | * Constructs a {@code FactorChangeEvent} object and sets the action. | |
| 21 | * | |
| 22 | * @param eventSource the originator of the event | |
| 23 | * @param newAction the action to be performed by listeners | |
| 24 | */ | |
| 25 | public FactorChangeEvent(final Object eventSource, final int newAction) | |
| 26 | { | |
| 27 | 0 | super(eventSource); |
| 28 | 0 | action = newAction; |
| 29 | 0 | } |
| 30 | ||
| 31 | /** | |
| 32 | * Constructs a {@code FactorChangeEvent} object and sets the conversion value. | |
| 33 | * | |
| 34 | * @param eventSource the originator of the event | |
| 35 | * @param value the conversion factor value | |
| 36 | * @param mw the molecular weight | |
| 37 | */ | |
| 38 | public FactorChangeEvent(final Object eventSource, final String value, final BigDecimal mw) | |
| 39 | { | |
| 40 | 0 | super(eventSource); |
| 41 | 0 | conversion = value; |
| 42 | 0 | molecularWeight = mw; |
| 43 | 0 | } |
| 44 | ||
| 45 | /** | |
| 46 | * Returns the conversion factor value | |
| 47 | * | |
| 48 | * @return the conversion factor value | |
| 49 | */ | |
| 50 | public final String getCoversion() | |
| 51 | { | |
| 52 | 0 | return conversion; |
| 53 | } | |
| 54 | ||
| 55 | /** | |
| 56 | * Returns the event's action | |
| 57 | * | |
| 58 | * @return the event's action | |
| 59 | */ | |
| 60 | public final int getAction() | |
| 61 | { | |
| 62 | 0 | return action; |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * Returns the molecular weight, default is 1 | |
| 67 | * | |
| 68 | * @return the molecular weight, default is 1 | |
| 69 | */ | |
| 70 | public final BigDecimal getMolecularWeight() | |
| 71 | { | |
| 72 | 0 | return molecularWeight; |
| 73 | } | |
| 74 | } |