All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nakedobjects.example.expenses.claims.items.CarRental Maven / Gradle / Ivy

The newest version!
package org.nakedobjects.example.expenses.claims.items;

import org.nakedobjects.applib.annotation.MemberOrder;
import org.nakedobjects.example.expenses.claims.ExpenseItem;




public class CarRental extends AbstractExpenseItem {

    // {{ Rental Company
    private String rentalCompany;

    public void setRentalCompany(final String rentalCompany) {
        this.rentalCompany = rentalCompany;
        objectChanged();
    }

    @MemberOrder(sequence="2.1")
	public String getRentalCompany() {
        resolve(rentalCompany);
        return rentalCompany;
    }

    public void modifyRentalCompany(final String newRentalCompany) {
        setRentalCompany(newRentalCompany);
        checkIfComplete();
    }
    
    public void clearRentalCompany() {
        setRentalCompany(null);
        checkIfComplete();
    }
    

    public String disableRentalCompany() {
        return disabledIfLocked();
    }
    // }}
    
    // {{ Number of Days
    private int numberOfDays = 0;

    public void setNumberOfDays(int noOfDays) {
        this.numberOfDays = noOfDays;
        objectChanged();
    }

    @MemberOrder(sequence="2.2")
	public int getNumberOfDays() {
        resolve();
        return numberOfDays;
    }

    public void modifyNumberOfDays(int noOfDays) {
        setNumberOfDays(noOfDays);
        checkIfComplete();
    }
    
    public void clearNumberOfDays() {
        setNumberOfDays(0);
        checkIfComplete();
    }


    public String disableNumberOfDays() {
        return disabledIfLocked();
    }
    // }}

    // {{ Copying
	@Override
	protected void copyAnyEmptyFieldsSpecificToSubclassOfAbstractExpenseItem(ExpenseItem otherItem) {
		if (otherItem instanceof CarRental) {
			CarRental carRental = (CarRental) otherItem;
		
		 if (rentalCompany == null || rentalCompany.length() == 0) {
	            modifyRentalCompany(carRental.getRentalCompany());
	        }
		  if (numberOfDays == 0) {
	            modifyNumberOfDays(carRental.getNumberOfDays());
	        }
		}
	}
// }}

	@Override
	protected boolean mandatorySubClassFieldsComplete() {
		return numberOfDays > 0 && rentalCompany != null &! rentalCompany.equals("");
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy