/*
 * Copyright (c) 2004-2017, by Alex Leigh.
 * All rights reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */

package lc.mecha.util;

import java.io.*;
import java.util.*;

/**
 * Implementation of <code>Properties</code> which is immutable.
 */
public class ImmutableProperties extends Properties {
    private static final long serialVersionUID = 1L;
    private final Properties properties;

    public ImmutableProperties(final Properties properties) {
        assert (properties != null);
        this.properties = properties;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized void clear() {
        throw new UnsupportedOperationException();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized Object clone() {
        return new ImmutableProperties(this.properties);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized boolean contains(final Object value) {
        return properties.contains(value);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean containsKey(final Object key) {
        return this.properties.containsKey(key);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean containsValue(final Object value) {
        return this.properties.containsValue(value);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Enumeration<Object> elements() {
        return this.properties.elements();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Set<Map.Entry<Object, Object>> entrySet() {
        return Collections.unmodifiableSet(super.entrySet());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(final Object o) {
        return this.properties.equals(o);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Object get(final Object key) {
        return this.properties.get(key);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getProperty(final String key) {
        return this.properties.getProperty(key);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getProperty(final String key, final String defaultValue) {
        return this.properties.getProperty(key, defaultValue);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {
        return this.properties.hashCode();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean isEmpty() {
        return this.properties.isEmpty();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Set<Object> keySet() {
        return Collections.unmodifiableSet(super.keySet());
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Enumeration<Object> keys() {
        return this.properties.keys();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void list(final PrintStream out) {
        this.properties.list(out);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void list(final PrintWriter out) {
        this.properties.list(out);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized void load(final InputStream inStream) {
        throw new UnsupportedOperationException();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized void loadFromXML(final InputStream in) {
        throw new UnsupportedOperationException();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Enumeration<?> propertyNames() {
        return this.properties.propertyNames();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized Object put(final Object key, final Object value) {
        throw new UnsupportedOperationException();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized void putAll(final Map<?, ?> t) {
        throw new UnsupportedOperationException();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized Object remove(final Object key) {
        throw new UnsupportedOperationException();
    }

    /**
     * {@inheritDoc}
     *
     * @deprecated
     */
    @Deprecated
    @Override
    public void save(final OutputStream out, final String comments) {
        this.properties.save(out, comments);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public synchronized Object setProperty(final String key, final String value) {
        throw new UnsupportedOperationException();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int size() {
        return this.properties.size();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void store(final OutputStream out, final String comments) throws IOException {
        this.properties.store(out, comments);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void storeToXML(final OutputStream os, final String comment) throws IOException {
        this.properties.storeToXML(os, comment);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void storeToXML(final OutputStream os, final String comment, final String encoding) throws IOException {
        this.properties.storeToXML(os, comment, encoding);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return this.properties.toString();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Collection<Object> values() {
        return this.properties.values();
    }
}