epgtools.libepgupdate.updator.config.Config.java Source code

Java tutorial

Introduction

Here is the source code for epgtools.libepgupdate.updator.config.Config.java

Source

/*
 * 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 epgtools.libepgupdate.updator.config;

import java.io.File;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

/**
 * Updater????
 *
 * @author normal
 */
public final class Config {

    private final java.sql.Connection connection;

    private final File xMLDirectory;
    private final Charset xMLFileCharCode;
    private final Set<Integer> paidBroadcastings;

    /**
     * Updater????
     *
     * @param connection ?DB??
     * @param xMLDirectory EPG XML???????
     * @param xMLFileCharCode EPG XML?
     * @param paidBroadcastings ?????????(??)
     */
    public Config(java.sql.Connection connection, File xMLDirectory, Charset xMLFileCharCode,
            Set<Integer> paidBroadcastings) throws NullPointerException, IllegalArgumentException {
        if (connection != null) {
            this.connection = connection;
        } else {
            throw new NullPointerException("DB??????");
        }
        if (xMLDirectory != null && xMLDirectory.isDirectory()) {
            this.xMLDirectory = new File(xMLDirectory.getAbsolutePath());
        } else {
            throw new IllegalArgumentException(
                    "XML??????????");
        }
        if (xMLFileCharCode != null) {
            this.xMLFileCharCode = xMLFileCharCode;
        } else {
            throw new NullPointerException("XML???????");
        }
        if (paidBroadcastings != null && paidBroadcastings.size() >= 0) {
            Set<Integer> tempPaidBroadcastings = new HashSet<>();
            tempPaidBroadcastings.addAll(paidBroadcastings);
            this.paidBroadcastings = Collections.unmodifiableSet(tempPaidBroadcastings);
        } else {
            throw new IllegalArgumentException(
                    "?????????????");
        }
    }

    /**
     * @return DB
     */
    public synchronized java.sql.Connection getConention() {
        return connection;
    }

    /**
     * @return XML????
     */
    public synchronized File getXMLDirectory() {
        return new File(xMLDirectory.getAbsolutePath());
    }

    /**
     * @return XML?
     */
    public synchronized Charset getXMLFileCharCode() {
        return xMLFileCharCode;
    }

    /**
     * @return ?????
     */
    public synchronized Set<Integer> getPaidBroadcastings() {
        Set<Integer> tempPaidBroadcastings = new HashSet<>();
        tempPaidBroadcastings.addAll(paidBroadcastings);
        return Collections.unmodifiableSet(tempPaidBroadcastings);
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 43 * hash + Objects.hashCode(this.connection);
        hash = 43 * hash + Objects.hashCode(this.xMLDirectory);
        hash = 43 * hash + Objects.hashCode(this.xMLFileCharCode);
        hash = 43 * hash + Objects.hashCode(this.paidBroadcastings);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Config other = (Config) obj;
        if (!Objects.equals(this.connection, other.connection)) {
            return false;
        }
        if (!Objects.equals(this.xMLDirectory, other.xMLDirectory)) {
            return false;
        }
        if (!Objects.equals(this.xMLFileCharCode, other.xMLFileCharCode)) {
            return false;
        }
        if (!Objects.equals(this.paidBroadcastings, other.paidBroadcastings)) {
            return false;
        }
        return true;
    }

    /**
     * ???????
     *
     * @return ????????????
     */
    @Override
    public synchronized String toString() {
        return ReflectionToStringBuilder.toString(this);
    }
}