Singleton interface in Java
Your implementation fails to adhere to some important Object Oriented principles.


Encapsulation

The state of your singleton can be modified by others.

package a;

public class Cat implements Dog {

    static {
        State.age = 17;
    }

    public int age() {
        return Cat.getAge.f(null);
    }

    public void setAge(int age) {
        State.age = age;
    }

    public static void main(String[] args) {
        System.out.println(new Cat().age());
    }
}

Polymorphism

This is basically a problem that comes with the singleton pattern itself. However, a                             more conventional approach to implementing a singleton can deal with this issue :

package b;

public interface Dog {

    String getName();

    void die();

    void woof();
}


and the singleton implementation :

package b;

public enum SingleDog implements Dog {
    INSTANCE;

    private String name;
    private boolean dead;


    @Override
    public String getName() {
        return name;
    }

    @Override
    public void die() {
        System.out.println("X_X");
        dead = true;
    }

    @Override
    public void woof() {
        if (dead) {
            throw new IllegalStateException("cannot woof when dead");
        }
        System.out.println("woof");
    }
}


This way clients can depend on the interface and not the singleton implementation. i.e. that there can only be one instance is now an implementation detail, and not an unchangeable design decision.


If you want to do functional programming, Java is probably not the language you should be using.