Java tutorial
/* * Copyright (c) 2012, Robert von Burg * * All rights reserved. * * This file is part of the XXX. * * XXX is free software: you can redistribute * it and/or modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the License, * or (at your option) any later version. * * XXX is distributed in the hope that it will * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XXX. If not, see * <http://www.gnu.org/licenses/>. */ package ch.eitchnet.android.mabea.model; import org.joda.time.Duration; import org.joda.time.LocalDateTime; import org.joda.time.Period; import org.joda.time.ReadablePartial; /** * @author Robert von Burg <eitch@eitchnet.ch> * */ public class MabeaState { private String name; private Duration balance; private Duration remainingVacation; private LocalDateTime stateTime; private State state; private LocalDateTime timeQueried; /** * Default constructor */ public MabeaState() { this.timeQueried = LocalDateTime.now(); this.name = ""; this.state = State.UNKNOWN; } /** * Constructor to set all fields * * @param name * @param balance * @param remainingVacation * @param stateTime * @param state */ public MabeaState(String name, Duration balance, Duration remainingVacation, LocalDateTime stateTime, State state) { this.timeQueried = LocalDateTime.now(); this.name = name; this.balance = balance; this.remainingVacation = remainingVacation; this.stateTime = stateTime; this.state = state; } /** * @return the timeCreated */ public ReadablePartial getTimeQueried() { return this.timeQueried; } public Duration getAge() { return new Period(this.timeQueried, LocalDateTime.now()).toStandardDuration(); } /** * @return the name */ public String getName() { return this.name; } /** * @param name * the name to set */ public void setName(String name) { this.name = name; } /** * @return the balance */ public Duration getBalance() { return this.balance; } /** * @param balance * the balance to set */ public void setBalance(Duration balance) { this.balance = balance; } /** * @return the remainingHolidays */ public Duration getRemainingVacation() { return this.remainingVacation; } /** * @param remainingVacation * the remainingVacation to set */ public void setRemainingVacation(Duration remainingVacation) { this.remainingVacation = remainingVacation; } /** * @return the stateTime */ public LocalDateTime getStateTime() { return this.stateTime; } /** * @param stateTime * the stateTime to set */ public void setStateTime(LocalDateTime stateTime) { this.stateTime = stateTime; } /** * @return the state */ public State getState() { return this.state; } /** * @param state * the state to set */ public void setState(State state) { this.state = state; } public static enum State { UNKNOWN("type_info.x"), LOGGED_IN("type_kommt.x"), LOGGED_OUT("type_geht.x"); public final String actionId; private State(String actionId) { this.actionId = actionId; } } }