@SuppressWarnings("unchecked")
    public static <N, T> TKey<N, T> register(Class<N> namespace, String name, Class<T> type) {
        if (namespace == null) {
            throw new IllegalArgumentException("Namespace must not be null.");
        }
        if (name == null) {
            throw new IllegalArgumentException("Name must not be null.");
        }
        if (type == null) {
            throw new IllegalArgumentException("Type must not be null.");
        }

        synchronized (registry) {
            TKey<N, T> field = new TKey<>(namespace, name, type);

            TKey<?, ?> featureKey = registry.get(field);
            if (featureKey != null) {
                if (!featureKey.getType().equals(type)) {
                    throw new IllegalStateException(
                            "There is already a field registered with the name '"
                            + featureKey.getName() + "', but it specifies the type '"
                            + featureKey.getType().getName() + "' instead of '" + type.getName()
                            + "'");
                }
                return (TKey<N, T>) featureKey;
            } else {
                registry.put(field, field);
                return field;
            }
        }
    }