Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.gmail.gkovalechyn.automaticevents.parsing; import org.apache.commons.lang.Validate; /** * * @author Gabriel K */ public class IFloat extends Variable { public IFloat(String name) { super(VariableType.FLOAT, name); } @Override public String[] toArgs() { if (this.value == null) { this.value = (float) 0f; } return new String[] { Float.toString((float) this.value) }; } @Override public void setValue(Object value) { Validate.notNull(value); if (!(value instanceof Float)) { throw new IllegalArgumentException("Incompatible types: Float and " + value.getClass()); } else { this.value = value; } } @Override public void format(String format) { //useless } @Override public void fromArgs(String[] args) { if (args.length == 0) { this.value = 0f; } else { this.value = Float.parseFloat(args[0]); } } }