/*
 * #%L
 * Bio-Formats command line tools for reading and converting files
 * %%
 *   - Glencoe Software, Inc.
 *   - University of Dundee
 * %%
 * #L%
 */
/*
Contributed 2009 by the Center for BioImage Informatics, UCSB
*/
package loci.formats.tools;

import loci.formats.IFormatReader;
import loci.formats.IFormatWriter;
import loci.formats.ImageReader;
import loci.formats.ImageWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Utility class for printing a list of formats supported by Bio-Formats.
 */
public class PrintFormatTable {

    private static final Logger LOGGER = LoggerFactory.getLogger(PrintFormatTable.class);

    public enum PrintStyles {

        TXT, XML, HTML
    }

    // Text
    public static String getTextHeader() {
        return "";
    }

    public static String getTextFooter() {
        return "";
    }

    public static String getTextFormatLine(String name, boolean read, boolean write, boolean wmp, String ext) {
        StringBuffer s = new StringBuffer(name);
        if (read)
            s.append(": can read");
        if (write)
            s.append(", can write");
        if (wmp)
            s.append(", can write multiple");
        s.append(" (");
        s.append(ext);
        s.append(")");
        return s.toString();
    }

    // XML
    public static String getXmlHeader() {
        return "<response>\n";
    }

    public static String getXmlFooter() {
        return "</response>\n";
    }

    public static String getXmlFormatLine(String name, boolean read, boolean write, boolean wmp, String ext) {
        StringBuffer s = new StringBuffer("<format name='");
        s.append(name);
        s.append("'>\n");
        if (read)
            s.append("  <tag name='support' value='reading' />\n");
        if (write)
            s.append("  <tag name='support' value='writing' />\n");
        if (wmp) {
            s.append("  <tag name='support' value='writing multiple pages' />\n");
        }
        s.append("  <tag name='extensions' value='");
        s.append(ext.replace(", ", "|"));
        s.append("' />\n</format>\n");
        return s.toString();
    }

    // HTML
    public static String getHtmlHeader() {
        return "

Name	Reading	Writing	" + "Extensions
";
    }

    public static String getHtmlFooter() {
        return "
";
    }

    public static String getHtmlFormatLine(String name, boolean read, boolean write, String ext) {
        StringBuffer s = new StringBuffer("
");
        s.append(name);
        s.append("	");
        s.append(read ? "yes" : "no");
        s.append("	");
        s.append(write ? "yes" : "no");
        s.append("	");
        s.append(ext);
        s.append("
");
        return s.toString();
    }

    public static String getHeader(PrintStyles style) {
        if (style == PrintStyles.XML)
            return getXmlHeader();
        if (style == PrintStyles.HTML)
            return getHtmlHeader();
        if (style == PrintStyles.TXT)
            return getTextHeader();
        return "";
    }

    public static String getFooter(PrintStyles style) {
        if (style == PrintStyles.XML)
            return getXmlFooter();
        if (style == PrintStyles.HTML)
            return getHtmlFooter();
        if (style == PrintStyles.TXT)
            return getTextFooter();
        return "";
    }

    public static String getFormatLine(PrintStyles style, String name, boolean read, boolean write, boolean wmp, String ext) {
        if (style == PrintStyles.XML) {
            return getXmlFormatLine(name, read, write, wmp, ext);
        }
        if (style == PrintStyles.HTML) {
            return getHtmlFormatLine(name, read, write, ext);
        }
        if (style == PrintStyles.TXT) {
            return getTextFormatLine(name, read, write, wmp, ext);
        }
        return "";
    }

    public static void printSupportedFormats(String[] args) {
        PrintStyles printStyle = PrintStyles.TXT;
        boolean usage = false;
        if (args != null) {
            for (int i = 0; i < args.length; i++) {
                if (args[i].equals("-help"))
                    usage = true;
                else if (args[i].equals("-xml"))
                    printStyle = PrintStyles.XML;
                else if (args[i].equals("-html"))
                    printStyle = PrintStyles.HTML;
                else if (args[i].equals("-txt"))
                    printStyle = PrintStyles.TXT;
                else {
                    LOGGER.warn("unknown flag: {}; try -help for options", args[i]);
                }
            }
        }
        if (usage) {
            LOGGER.info("Usage: formatlist [-html] [-txt] [-xml]");
            LOGGER.info("  -html: show formats in an HTML table");
            LOGGER.info("   -txt: show formats in plaintext (default)");
            LOGGER.info("   -xml: show formats as XML data");
            return;
        }
        LOGGER.info(getHeader(printStyle));
        // retrieve all of the file format readers and writers
        ImageReader baseReader = new ImageReader();
        IFormatReader[] readers = baseReader.getReaders();
        ImageWriter baseWriter = new ImageWriter();
        IFormatWriter[] writers = baseWriter.getWriters();
        for (int i = 0; i < readers.length; i++) {
            String readerFormatName = readers[i].getFormat();
            boolean read = true;
            boolean write = false;
            boolean wmp = false;
            // check if there is a corresponding writer
            IFormatWriter writer = null;
            for (int j = 0; j < writers.length; j++) {
                if (writers[j].getFormat().equals(readerFormatName)) {
                    writer = writers[j];
                }
            }
            if (writer != null) {
                write = true;
                // this format can be written
                // determine whether or not multiple images can be
                // written to a single file
                if (writer.canDoStacks())
                    wmp = true;
            }
            String[] extensions = readers[i].getSuffixes();
            StringBuilder ext = new StringBuilder();
            for (int j = 0; j < extensions.length; j++) {
                ext.append(extensions[j]);
                if (j < extensions.length - 1) {
                    ext.append(", ");
                }
            }
            // display information about the format
            LOGGER.info(getFormatLine(printStyle, readerFormatName, read, write, wmp, ext.toString()));
        }
        LOGGER.info(getFooter(printStyle));
    }

{
        printSupportedFormats(args);
    }
}


{
        printSupportedFormats(args);
    }

/*
 * #%L
 * Bio-Formats command line tools for reading and converting files
 * %%
 *   - Glencoe Software, Inc.
 *   - University of Dundee
 * %%
 * #L%
 */
/*
Contributed 2009 by the Center for BioImage Informatics, UCSB
*/
package loci.formats.tools;

import loci.formats.IFormatReader;
import loci.formats.IFormatWriter;
import loci.formats.ImageReader;
import loci.formats.ImageWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Utility class for printing a list of formats supported by Bio-Formats.
 */
public class PrintFormatTable {

    private static final Logger LOGGER = LoggerFactory.getLogger(PrintFormatTable.class);

    public enum PrintStyles {

        TXT, XML, HTML
    }

    // Text
    public static String getTextHeader() {
        return "";
    }

    public static String getTextFooter() {
        return "";
    }

    public static String getTextFormatLine(String name, boolean read, boolean write, boolean wmp, String ext) {
        StringBuffer s = new StringBuffer(name);
        if (read)
            s.append(": can read");
        if (write)
            s.append(", can write");
        if (wmp)
            s.append(", can write multiple");
        s.append(" (");
        s.append(ext);
        s.append(")");
        return s.toString();
    }

    // XML
    public static String getXmlHeader() {
        return "<response>\n";
    }

    public static String getXmlFooter() {
        return "</response>\n";
    }

    public static String getXmlFormatLine(String name, boolean read, boolean write, boolean wmp, String ext) {
        StringBuffer s = new StringBuffer("<format name='");
        s.append(name);
        s.append("'>\n");
        if (read)
            s.append("  <tag name='support' value='reading' />\n");
        if (write)
            s.append("  <tag name='support' value='writing' />\n");
        if (wmp) {
            s.append("  <tag name='support' value='writing multiple pages' />\n");
        }
        s.append("  <tag name='extensions' value='");
        s.append(ext.replace(", ", "|"));
        s.append("' />\n</format>\n");
        return s.toString();
    }

    // HTML
    public static String getHtmlHeader() {
        return "

Name	Reading	Writing	" + "Extensions
";
    }

    public static String getHtmlFooter() {
        return "
";
    }

    public static String getHtmlFormatLine(String name, boolean read, boolean write, String ext) {
        StringBuffer s = new StringBuffer("
");
        s.append(name);
        s.append("	");
        s.append(read ? "yes" : "no");
        s.append("	");
        s.append(write ? "yes" : "no");
        s.append("	");
        s.append(ext);
        s.append("
");
        return s.toString();
    }

    public static String getHeader(PrintStyles style) {
        if (style == PrintStyles.XML)
            return getXmlHeader();
        if (style == PrintStyles.HTML)
            return getHtmlHeader();
        if (style == PrintStyles.TXT)
            return getTextHeader();
        return "";
    }

    public static String getFooter(PrintStyles style) {
        if (style == PrintStyles.XML)
            return getXmlFooter();
        if (style == PrintStyles.HTML)
            return getHtmlFooter();
        if (style == PrintStyles.TXT)
            return getTextFooter();
        return "";
    }

    public static String getFormatLine(PrintStyles style, String name, boolean read, boolean write, boolean wmp, String ext) {
        if (style == PrintStyles.XML) {
            return getXmlFormatLine(name, read, write, wmp, ext);
        }
        if (style == PrintStyles.HTML) {
            return getHtmlFormatLine(name, read, write, ext);
        }
        if (style == PrintStyles.TXT) {
            return getTextFormatLine(name, read, write, wmp, ext);
        }
        return "";
    }

    public static void printSupportedFormats(String[] args) {
        PrintStyles printStyle = PrintStyles.TXT;
        boolean usage = false;
        if (args != null) {
            for (int i = 0; i < args.length; i++) {
                if (args[i].equals("-help"))
                    usage = true;
                else if (args[i].equals("-xml"))
                    printStyle = PrintStyles.XML;
                else if (args[i].equals("-html"))
                    printStyle = PrintStyles.HTML;
                else if (args[i].equals("-txt"))
                    printStyle = PrintStyles.TXT;
                else {
                    LOGGER.warn("unknown flag: {}; try -help for options", args[i]);
                }
            }
        }
        if (usage) {
            LOGGER.info("Usage: formatlist [-html] [-txt] [-xml]");
            LOGGER.info("  -html: show formats in an HTML table");
            LOGGER.info("   -txt: show formats in plaintext (default)");
            LOGGER.info("   -xml: show formats as XML data");
            return;
        }
        LOGGER.info(getHeader(printStyle));
        // retrieve all of the file format readers and writers
        ImageReader baseReader = new ImageReader();
        IFormatReader[] readers = baseReader.getReaders();
        ImageWriter baseWriter = new ImageWriter();
        IFormatWriter[] writers = baseWriter.getWriters();
        for (int i = 0; i < readers.length; i++) {
            String readerFormatName = readers[i].getFormat();
            boolean read = true;
            boolean write = false;
            boolean wmp = false;
            // check if there is a corresponding writer
            IFormatWriter writer = null;
            for (int j = 0; j < writers.length; j++) {
                if (writers[j].getFormat().equals(readerFormatName)) {
                    writer = writers[j];
                }
            }
            if (writer != null) {
                write = true;
                // this format can be written
                // determine whether or not multiple images can be
                // written to a single file
                if (writer.canDoStacks())
                    wmp = true;
            }
            String[] extensions = readers[i].getSuffixes();
            StringBuilder ext = new StringBuilder();
            for (int j = 0; j < extensions.length; j++) {
                ext.append(extensions[j]);
                if (j < extensions.length - 1) {
                    ext.append(", ");
                }
            }
            // display information about the format
            LOGGER.info(getFormatLine(printStyle, readerFormatName, read, write, wmp, ext.toString()));
        }
        LOGGER.info(getFooter(printStyle));
    }

    public static void main(String[] args)


/*
 * #%L
 * Bio-Formats command line tools for reading and converting files
 * %%
 *   - Glencoe Software, Inc.
 *   - University of Dundee
 * %%
 * #L%
 */
/*
Contributed 2009 by the Center for BioImage Informatics, UCSB
*/
package loci.formats.tools;

import loci.formats.IFormatReader;
import loci.formats.IFormatWriter;
import loci.formats.ImageReader;
import loci.formats.ImageWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Utility class for printing a list of formats supported by Bio-Formats.
 */
public class PrintFormatTable {

    private static final Logger LOGGER = LoggerFactory.getLogger(PrintFormatTable.class);

    public enum PrintStyles {

        TXT, XML, HTML
    }

    // Text
    public static String getTextHeader() {
        return "";
    }

    public static String getTextFooter() {
        return "";
    }

    public static String getTextFormatLine(String name, boolean read, boolean write, boolean wmp, String ext) {
        StringBuffer s = new StringBuffer(name);
        if (read)
            s.append(": can read");
        if (write)
            s.append(", can write");
        if (wmp)
            s.append(", can write multiple");
        s.append(" (");
        s.append(ext);
        s.append(")");
        return s.toString();
    }

    // XML
    public static String getXmlHeader() {
        return "<response>\n";
    }

    public static String getXmlFooter() {
        return "</response>\n";
    }

    public static String getXmlFormatLine(String name, boolean read, boolean write, boolean wmp, String ext) {
        StringBuffer s = new StringBuffer("<format name='");
        s.append(name);
        s.append("'>\n");
        if (read)
            s.append("  <tag name='support' value='reading' />\n");
        if (write)
            s.append("  <tag name='support' value='writing' />\n");
        if (wmp) {
            s.append("  <tag name='support' value='writing multiple pages' />\n");
        }
        s.append("  <tag name='extensions' value='");
        s.append(ext.replace(", ", "|"));
        s.append("' />\n</format>\n");
        return s.toString();
    }

    // HTML
    public static String getHtmlHeader() {
        return "

Name	Reading	Writing	" + "Extensions
";
    }

    public static String getHtmlFooter() {
        return "
";
    }

    public static String getHtmlFormatLine(String name, boolean read, boolean write, String ext) {
        StringBuffer s = new StringBuffer("
");
        s.append(name);
        s.append("	");
        s.append(read ? "yes" : "no");
        s.append("	");
        s.append(write ? "yes" : "no");
        s.append("	");
        s.append(ext);
        s.append("
");
        return s.toString();
    }

    public static String getHeader(PrintStyles style) {
        if (style == PrintStyles.XML)
            return getXmlHeader();
        if (style == PrintStyles.HTML)
            return getHtmlHeader();
        if (style == PrintStyles.TXT)
            return getTextHeader();
        return "";
    }

    public static String getFooter(PrintStyles style) {
        if (style == PrintStyles.XML)
            return getXmlFooter();
        if (style == PrintStyles.HTML)
            return getHtmlFooter();
        if (style == PrintStyles.TXT)
            return getTextFooter();
        return "";
    }

    public static String getFormatLine(PrintStyles style, String name, boolean read, boolean write, boolean wmp, String ext) {
        if (style == PrintStyles.XML) {
            return getXmlFormatLine(name, read, write, wmp, ext);
        }
        if (style == PrintStyles.HTML) {
            return getHtmlFormatLine(name, read, write, ext);
        }
        if (style == PrintStyles.TXT) {
            return getTextFormatLine(name, read, write, wmp, ext);
        }
        return "";
    }

    public static void printSupportedFormats(String[] args) {
        PrintStyles printStyle = PrintStyles.TXT;
        boolean usage = false;
        if (args != null) {
            for (int i = 0; i < args.length; i++) {
                if (args[i].equals("-help"))
                    usage = true;
                else if (args[i].equals("-xml"))
                    printStyle = PrintStyles.XML;
                else if (args[i].equals("-html"))
                    printStyle = PrintStyles.HTML;
                else if (args[i].equals("-txt"))
                    printStyle = PrintStyles.TXT;
                else {
                    LOGGER.warn("unknown flag: {}; try -help for options", args[i]);
                }
            }
        }
        if (usage) {
            LOGGER.info("Usage: formatlist [-html] [-txt] [-xml]");
            LOGGER.info("  -html: show formats in an HTML table");
            LOGGER.info("   -txt: show formats in plaintext (default)");
            LOGGER.info("   -xml: show formats as XML data");
            return;
        }
        LOGGER.info(getHeader(printStyle));
        // retrieve all of the file format readers and writers
        ImageReader baseReader = new ImageReader();
        IFormatReader[] readers = baseReader.getReaders();
        ImageWriter baseWriter = new ImageWriter();
        IFormatWriter[] writers = baseWrite

        for (int i = 0; i < readers.length; i++) {
            String readerFormatName = readers[i].getFormat();
            boolean read = true;
            boolean write = false;
            boolean wmp = false;
            // check if there is a corresponding writer
            IFormatWriter writer = null;
            for (int j = 0; j < writers.length; j++) {
                if (writers[j].getFormat().equals(readerFormatName)) {
                    writer = writers[j];
                }
            }
            if (writer != null) {
                write = true;
                // this format can be written
                // determine whether or not multiple images can be
                // written to a single file
                if (writer.canDoStacks())
                    wmp = true;
            }
            String[] extensions = readers[i].getSuffixes();
            StringBuilder ext = new StringBuilder();
            for (int j = 0; j < extensions.length; j++) {
                ext.append(extensions[j]);
                if (j < extensions.length - 1) {
                    ext.append(", ");
                }
            }
            // display information about the format
            LOGGER.info(getFormatLine(printStyle, readerFormatName, read, write, wmp, ext.toString()));
        }
        LOGGER.info(getFooter(printStyle));
    }

    public static void main(String[] args) {
        printSupportedFormats(args);
    }
}


for (int j = 0; j < extensions.length; j++) {
                ext.append(extensions[j]);
                if (j < extensions.length - 1) {
                    ext.append(", ");
                }
            }

/*
 * #%L
 * Bio-Formats command line tools for reading and converting files
 * %%
 *   - Glencoe Software, Inc.
 *   - University of Dundee
 * %%
 * #L%
 */
/*
Contributed 2009 by the Center for BioImage Informatics, UCSB
*/
package loci.formats.tools;

import loci.formats.IFormatReader;
import loci.formats.IFormatWriter;
import loci.formats.ImageReader;
import loci.formats.ImageWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Utility class for printing a list of formats supported by Bio-Formats.
 */
public class PrintFormatTable {

    private static final Logger LOGGER = LoggerFactory.getLogger(PrintFormatTable.class);

    public enum PrintStyles {

        TXT, XML, HTML
    }

    // Text
    public static String getTextHeader() {
        return "";
    }

    public static String getTextFooter() {
        return "";
    }

    public static String getTextFormatLine(String name, boolean read, boolean write, boolean wmp, String ext) {
        StringBuffer s = new StringBuffer(name);
        if (read)
            s.append(": can read");
        if (write)
            s.append(", can write");
        if (wmp)
            s.append(", can write multiple");
        s.append(" (");
        s.append(ext);
        s.append(")");
        return s.toString();
    }

    // XML
    public static String getXmlHeader() {
        return "<response>\n";
    }

    public static String getXmlFooter() {
        return "</response>\n";
    }

    public static String getXmlFormatLine(String name, boolean read, boolean write, boolean wmp, String ext) {
        StringBuffer s = new StringBuffer("<format name='");
        s.append(name);
        s.append("'>\n");
        if (read)
            s.append("  <tag name='support' value='reading' />\n");
        if (write)
            s.append("  <tag name='support' value='writing' />\n");
        if (wmp) {
            s.append("  <tag name='support' value='writing multiple pages' />\n");
        }
        s.append("  <tag name='extensions' value='");
        s.append(ext.replace(", ", "|"));
        s.append("' />\n</format>\n");
        return s.toString();
    }

    // HTML
    public static String getHtmlHeader() {
        return "

Name	Reading	Writing	" + "Extensions
";
    }

    public static String getHtmlFooter() {
        return "
";
    }

    public static String getHtmlFormatLine(String name, boolean read, boolean write, String ext) {
        StringBuffer s = new StringBuffer("
");
        s.append(name);
        s.append("	");
        s.append(read ? "yes" : "no");
        s.append("	");
        s.append(write ? "yes" : "no");
        s.append("	");
        s.append(ext);
        s.append("
");
        return s.toString();
    }

    public static String getHeader(PrintStyles style) {
        if (style == PrintStyles.XML)
            return getXmlHeader();
        if (style == PrintStyles.HTML)
            return getHtmlHeader();
        if (style == PrintStyles.TXT)
            return getTextHeader();
        return "";
    }

    public static String getFooter(PrintStyles style) {
        if (style == PrintStyles.XML)
            return getXmlFooter();
        if (style == PrintStyles.HTML)
            return getHtmlFooter();
        if (style == PrintStyles.TXT)
            return getTextFooter();
        return "";
    }

    public static String getFormatLine(PrintStyles style, String name, boolean read, boolean write, boolean wmp, String ext) {
        if (style == PrintStyles.XML) {
            return getXmlFormatLine(name, read, write, wmp, ext);
        }
        if (style == PrintStyles.HTML) {
            return getHtmlFormatLine(name, read, write, ext);
        }
        if (style == PrintStyles.TXT) {
            return getTextFormatLine(name, read, write, wmp, ext);
        }
        return "";
    }

    public static void printSupportedFormats(String[] args) {
        PrintStyles printStyle = PrintStyles.TXT;
        boolean usage = false;
        if (args != null) {
            for (int i = 0; i < args.length; i++) {
                if (args[i].equals("-help"))
                    usage = true;
                else if (args[i].equals("-xml"))
                    printStyle = PrintStyles.XML;
                else if (args[i].equals("-html"))
                    printStyle = PrintStyles.HTML;
                else if (args[i].equals("-txt"))
                    printStyle = PrintStyles.TXT;
                else {
                    LOGGER.warn("unknown flag: {}; try -help for options", args[i]);
                }
            }
        }
        if (usage) {
            LOGGER.info("Usage: formatlist [-html] [-txt] [-xml]");
            LOGGER.info("  -html: show formats in an HTML table");
            LOGGER.info("   -txt: show formats in plaintext (default)");
            LOGGER.info("   -xml: show formats as XML data");
            return;
        }
        LOGGER.info(getHeader(printStyle));
        // retrieve all of the file format readers and writers
        ImageReader baseReader = new ImageReader();
        IFormatReader[] readers = baseReader.getReaders();
        ImageWriter baseWriter = new ImageWriter();
        IFormatWriter[] writers = baseWriter.getWriters();
        for (int i = 0; i < readers.length; i++) {
            String readerFormatName = readers[i].getFormat();
            boolean read = true;
            boolean write = false;
            boolean wmp = false;
            // check if there is a corresponding writer
            IFormatWriter writer = null;
            for (int j = 0; j < writers.length; j++) {
                if (writers[j].getFormat().equals(readerFormatName)) {
                    writer = writers[j];
                }
            }
            if (writer != null) {
                write = true;
                // this format can be written
                // determine whether or not multiple images can be
                // written to a single file
                if (writer.canDoStacks())
                    wmp = true;
            }
            String[] extensions = readers[i].getSuffixes();
            StringBuilder ext = new StringBuilder();

            // display information about the format
            LOGGER.info(getFormatLine(printStyle, readerFormatName, read, write, wmp, ext.toString()));
        }
        LOGGER.info(getFooter(printStyle));
    }

    public static void main(String[] args) {
        printSupportedFormats(args);
    }
}


public MappingConfiguration<S, D> to(FieldSelector<D> destinationSelector)

package com.remondis.remap;

import static com.remondis.remap.Lang.denyNull;
import static com.remondis.remap.MappingConfiguration.getPropertyFromFieldSelector;
import java.beans.PropertyDescriptor;

/**
 * Builds a reassign operation.
 *
 * @param <S> The source type.
 * @param <D> The destination type.
 */
public class ReassignBuilder<S, D> {

    static final String ASSIGN = "assign";

    private PropertyDescriptor sourceProperty;

    private MappingConfiguration<S, D> mapping;

    private Class<D> destination;

    ReassignBuilder(PropertyDescriptor sourceProperty, Class<D> destination, MappingConfiguration<S, D> mapping) {
        super();
        this.sourceProperty = sourceProperty;
        this.mapping = mapping;
        this.destination = destination;
    }

    /**
     * Reassigns a source field to the specified destination field.
     *
     * @param destinationSelector
     *        {@link TypedSelector} to select the destination field.
     *
     * @return Returns the {@link MappingConfiguration} for further mapping configuration.
     */

{
        denyNull("destinationSelector", destinationSelector);
        PropertyDescriptor destProperty = getPropertyFromFieldSelector(Target.DESTINATION, ASSIGN, destination, destinationSelector);
        ReassignTransformation transformation = new ReassignTransformation(mapping, sourceProperty, destProperty);
        mapping.addMapping(sourceProperty, destProperty, transformation);
        return mapping;
    }
}


{
        denyNull("destinationSelector", destinationSelector);
        PropertyDescriptor destProperty = getPropertyFromFieldSelector(Target.DESTINATION, ASSIGN, destination, destinationSelector);
        ReassignTransformation transformation = new ReassignTransformation(mapping, sourceProperty, destProperty);
        mapping.addMapping(sourceProperty, destProperty, transformation);
        return mapping;
    }

package com.remondis.remap;

import static com.remondis.remap.Lang.denyNull;
import static com.remondis.remap.MappingConfiguration.getPropertyFromFieldSelector;
import java.beans.PropertyDescriptor;

/**
 * Builds a reassign operation.
 *
 * @param <S> The source type.
 * @param <D> The destination type.
 */
public class ReassignBuilder<S, D> {

    static final String ASSIGN = "assign";

    private PropertyDescriptor sourceProperty;

    private MappingConfiguration<S, D> mapping;

    private Class<D> destination;

    ReassignBuilder(PropertyDescriptor sourceProperty, Class<D> destination, MappingConfiguration<S, D> mapping) {
        super();
        this.sourceProperty = sourceProperty;
        this.mapping = mapping;
        this.destination = destination;
    }

    /**
     * Reassigns a source field to the specified destination field.
     *
     * @param destinationSelector
     *        {@link TypedSelector} to select the destination field.
     *
     * @return Returns the {@link MappingConfiguration} for further mapping configuration.
     */
    public MappingConfiguration<S, D> to(FieldSelector<D> destinationSelector)


package com.remondis.remap;

import static com.remondis.remap.Lang.denyNull;
import static com.remondis.remap.MappingConfiguration.getPropertyFromFieldSelector;
import java.beans.PropertyDescriptor;

/**
 * Builds a reassign operation.
 *
 * @param <S> The source type.
 * @param <D> The destination type.
 */
public class ReassignBuilder<S, D> {

    static final String ASSIGN = "assign";

    private PropertyDescriptor sourceProperty;

    private MappingConfiguration<S, D> mapping;

    private Class<D> destination;

    ReassignBuilder(PropertyDescriptor sourceProperty, Class<D> destination, MappingConfiguration<S, D> mapping) {
        super();
        this.sourceProperty = sourceProperty;
        this.mapping = mapping;
        this.destination = destination;
    }

    /**
     * Reassigns a source field to the specified destination field.
     *
     * @param destinationSelector
     *        {@link TypedSelector} to select the destination field.
     *
     * @return Returns the {@link MappingConfiguration} for further mapping configuration.
     */
    public MappingConfiguration<S, D> to(FieldSelector<D> destinationSelector) {
        denyNull(

        PropertyDescriptor destProperty = getPropertyFromFieldSelector(Target.DESTINATION, ASSIGN, destination, destinationSelector);
        ReassignTransformation transformation = new ReassignTransformation(mapping, sourceProperty, destProperty);
        mapping.addMapping(sourceProperty, destProperty, transformation);
        return mapping;
    }
}


public MappingConfiguration<S, D> to(FieldSelector<D> destinationSelector) {
        denyNull("destinationSelector", destinationSelector);
        PropertyDescriptor destProperty = getPropertyFromFieldSelector(Target.DESTINATION, ASSIGN, destination, destinationSelector);
        ReassignTransformation transformation = new ReassignTransformation(mapping, sourceProperty, destProperty);
        mapping.addMapping(sourceProperty, destProperty, transformation);
        return mapping;
    }


public static boolean isEmpty(CharSequence data)

package io.plactal.eoscommander.util;

public class StringUtils {

{
        return (null == data) || (data.length() <= 0);
    }
}


{
        return (null == data) || (data.length() <= 0);
    }

package io.plactal.eoscommander.util;

public class StringUtils {

    public static boolean isEmpty(CharSequence data)


package io.plactal.eoscommander.util;

public class StringUtils {

    public static boolean isEmpty(CharSequence data) {
        return (null == data)


@Override
        protected void onProgressUpdate(Integer... values)

package com.lack006.hosts_l.Download;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.Toast;
import com.lack006.hosts_l.Consistent.Consistent;
import com.lack006.hosts_l.CleanCache.CleanCacheHelper;
import com.lack006.hosts_l.Clash.InsertClashTaskHelper;
import com.lack006.hosts_l.R;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import static com.lack006.hosts_l.Consistent.Consistent.CONNECTED;
import static com.lack006.hosts_l.Consistent.Consistent.CUSTOM_ERROR;
import static com.lack006.hosts_l.Consistent.Consistent.DOWNLOAD_CANCEL;
import static com.lack006.hosts_l.Consistent.Consistent.MIX_HOSTS;
import static com.lack006.hosts_l.Consistent.Consistent.TIME_OUT;

/**
 * Created by lack on 2016/12/15.
 * AndroidHosts-LV7
 */
public class CustomDownloadTaskHelper {

    private Context mContext = null;

    private ProgressDialog mProgressDialog = null;

    private ProgressDialog mMixProgressDialog = null;

    private CheckBox mCheckBox = null;

    private String[] mHosts = null;

    private boolean[] mCheck = null;

    private boolean mStopFlag = false;

    private boolean mIsReError = false;

    private boolean mIsKeepScreenOn = false;

    private String mUrl = null;

    public void download(Context context, String url, String[] hosts, boolean[] check, CheckBox checkBox, boolean keepScreenOn) {
        mContext = context;
        mHosts = hosts;
        mCheck = check;
        mCheckBox = checkBox;
        mUrl = url;
        mIsKeepScreenOn = keepScreenOn;
        CleanCacheHelper cleanCacheHelper = new CleanCacheHelper();
        cleanCacheHelper.cleanHosts(mContext);
        mProgressDialog = new ProgressDialog(mContext);
        mProgressDialog.setMessage(mContext.getString(R.string.connecting));
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setCancelable(false);
        mProgressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                mProgressDialog.setProgress(Consistent.DOWNLOAD_CANCEL);
                mStopFlag = true;
            }
        });
        mProgressDialog.show();
        DownloadHostsTask downloadHostsTask = new DownloadHostsTask();
        downloadHostsTask.execute();
    }

    private class DownloadHostsTask extends AsyncTask<Object, Integer, Boolean> {

        @Override
        protected Boolean doInBackground(Object... objects) {
            File file = mContext.getCacheDir();
            final String CACHE_PATH = file.getAbsolutePath();
            URL url;
            long fileSize;
            long downloadSize = 0;
            try {
                url = new URL(mContext.getString(R.string.ad_url));
                HttpURLConnection con = (HttpURLConnection) url.openConnection();
                con.setConnectTimeout(TIME_OUT);
                con.setRequestProperty("Accept-Encoding", "identity");
                InputStream in = con.getInputStream();
                File fileOut = new File(CACHE_PATH + Consistent.HOSTS_FILE);
                FileOutputStream out = new FileOutputStream(fileOut);
                byte[] bytes = new byte[1024];
                int len;
                fileSize = con.getContentLength();
                publishProgress(Consistent.CONNECTED);
                while ((len = in.read(bytes)) != -1) {
                    if (mStopFlag) {
                        con.disconnect();
                        break;
                    }
                    out.write(bytes, 0, len);
                    downloadSize += len;
                    publishProgress((int) (downloadSize * 100 / fileSize));
                }
                in.close();
                out.close();
                downloadSize = 0;
                publishProgress(0);
                if (!mStopFlag) {
                    mIsReError = true;
                    url = new URL(mUrl);
                    con = (HttpURLConnection) url.openConnection();
                    con.setConnectTimeout(TIME_OUT);
                    con.setRequestProperty("Accept-Encoding", "identity");
                    in = con.getInputStream();
                    fileOut = new File(CACHE_PATH + Consistent.RE_FILE);
                    out = new FileOutputStream(fileOut);
                    bytes = new byte[1024];
                    fileSize = con.getContentLength();
                    publishProgress(Consistent.CONNECTED);
                    while ((len = in.read(bytes)) != -1) {
                        if (mStopFlag) {
                            con.disconnect();
                            break;
                        }
                        out.write(bytes, 0, len);
                        downloadSize += len;
                        publishProgress((int) (downloadSize * 100 / fileSize));
                    }
                    in.close();
                    out.close();
                    publishProgress(Consistent.MIX_HOSTS);
                    mixHosts();
                }
            } catch (Exception e) {
                e.printStackTrace();
                mStopFlag = true;
                if (mIsReError) {
                    publishProgress(Consistent.CUSTOM_ERROR);
                } else {
                    publishProgress(Consistent.DOWNLOAD_CANCEL);
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(Boolean result) {
            if (mIsKeepScreenOn) {
                ((Activity) mContext).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                Toast.makeText(mContext, mContext.getString(R.string.keep_screen_on_hint_off), Toast.LENGTH_SHORT).show();
            }
            if (!mStopFlag) {
                mMixProgressDialog.cancel();
                InsertClashTaskHelper insertClashTaskHelper = new InsertClashTaskHelper();
                insertClashTaskHelper.insertClashHelper(mContext, mHosts, mCheck, mCheckBox);
            } else {
                CleanCacheHelper cleanCacheHelper = new CleanCacheHelper();
                cleanCacheHelper.cleanHosts(mContext);
            }
        }

{
            if (values[0] == CONNECTED) {
                mProgressDialog.setMessage(mContext.getString(R.string.downloading));
            } else if (values[0] == DOWNLOAD_CANCEL) {
                mProgressDialog.cancel();
            } else if (values[0] == MIX_HOSTS) {
                if (mIsKeepScreenOn) {
                    ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                    Toast.makeText(mContext, mContext.getString(R.string.keep_screen_on_hint_on), Toast.LENGTH_SHORT).show();
                }
                mProgressDialog.cancel();
                mMixProgressDialog = new ProgressDialog(mContext);
                mMixProgressDialog.setMessage(mContext.getString(R.string.mix_hosts));
                mMixProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                mMixProgressDialog.setIndeterminate(true);
                mMixProgressDialog.setCancelable(false);
                mMixProgressDialog.show();
            } else if (values[0] == CUSTOM_ERROR) {
                Toast.makeText(mContext, mContext.getString(R.string.custom_error), Toast.LENGTH_SHORT).show();
                mProgressDialog.cancel();
            } else {
                mProgressDialog.setProgress(values[0]);
            }
        }

        void mixHosts() {
            File file = mContext.getCacheDir();
            final String CACHE_PATH = file.getAbsolutePath();
            List<String> mReClashList = new ArrayList<>();
            try {
                BufferedReader adReader;
                adReader = new BufferedReader(new FileReader(CACHE_PATH + Consistent.HOSTS_FILE));
                String line;
                while ((line = adReader.readLine()) != null) {
                    if (!(line.contains(Consistent.HASH_TAG) || line.equals(""))) {
                        mReClashList.add(line.replace(Consistent.LOCAL_HOST + " ", ""));
                    }
                }
                adReader.close();
                BufferedReader reReader = new BufferedReader(new FileReader(CACHE_PATH + Consistent.RE_FILE));
                FileOutputStream fileOutputStream = new FileOutputStream(CACHE_PATH + Consistent.HOSTS_FILE, true);
                boolean flag = false;
                while ((line = reReader.readLine()) != null) {
                    for (String tmp : mReClashList) {
                        if (line.contains(tmp)) {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag) {
                        fileOutputStream.write((line + "\n").getBytes());
                    } else {
                        flag = false;
                    }
                }
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


{
                mProgressDialog.setProgress(Consistent.DOWNLOAD_CANCEL);
                mStopFlag = true;
            }

package com.lack006.hosts_l.Download;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.Toast;
import com.lack006.hosts_l.Consistent.Consistent;
import com.lack006.hosts_l.CleanCache.CleanCacheHelper;
import com.lack006.hosts_l.Clash.InsertClashTaskHelper;
import com.lack006.hosts_l.R;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import static com.lack006.hosts_l.Consistent.Consistent.CONNECTED;
import static com.lack006.hosts_l.Consistent.Consistent.CUSTOM_ERROR;
import static com.lack006.hosts_l.Consistent.Consistent.DOWNLOAD_CANCEL;
import static com.lack006.hosts_l.Consistent.Consistent.MIX_HOSTS;
import static com.lack006.hosts_l.Consistent.Consistent.TIME_OUT;

/**
 * Created by lack on 2016/12/15.
 * AndroidHosts-LV7
 */
public class CustomDownloadTaskHelper {

    private Context mContext = null;

    private ProgressDialog mProgressDialog = null;

    private ProgressDialog mMixProgressDialog = null;

    private CheckBox mCheckBox = null;

    private String[] mHosts = null;

    private boolean[] mCheck = null;

    private boolean mStopFlag = false;

    private boolean mIsReError = false;

    private boolean mIsKeepScreenOn = false;

    private String mUrl = null;

    public void download(Context context, String url, String[] hosts, boolean[] check, CheckBox checkBox, boolean keepScreenOn) {
        mContext = context;
        mHosts = hosts;
        mCheck = check;
        mCheckBox = checkBox;
        mUrl = url;
        mIsKeepScreenOn = keepScreenOn;
        CleanCacheHelper cleanCacheHelper = new CleanCacheHelper();
        cleanCacheHelper.cleanHosts(mContext);
        mProgressDialog = new ProgressDialog(mContext);
        mProgressDialog.setMessage(mContext.getString(R.string.connecting));
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setCancelable(false);
        mProgressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which)

        });
        mProgressDialog.show();
        DownloadHostsTask downloadHostsTask = new DownloadHostsTask();
        downloadHostsTask.execute();
    }

    private class DownloadHostsTask extends AsyncTask<Object, Integer, Boolean> {

        @Override
        protected Boolean doInBackground(Object... objects) {
            File file = mContext.getCacheDir();
            final String CACHE_PATH = file.getAbsolutePath();
            URL url;
            long fileSize;
            long downloadSize = 0;
            try {
                url = new URL(mContext.getString(R.string.ad_url));
                HttpURLConnection con = (HttpURLConnection) url.openConnection();
                con.setConnectTimeout(TIME_OUT);
                con.setRequestProperty("Accept-Encoding", "identity");
                InputStream in = con.getInputStream();
                File fileOut = new File(CACHE_PATH + Consistent.HOSTS_FILE);
                FileOutputStream out = new FileOutputStream(fileOut);
                byte[] bytes = new byte[1024];
                int len;
                fileSize = con.getContentLength();
                publishProgress(Consistent.CONNECTED);
                while ((len = in.read(bytes)) != -1) {
                    if (mStopFlag) {
                        con.disconnect();
                        break;
                    }
                    out.write(bytes, 0, len);
                    downloadSize += len;
                    publishProgress((int) (downloadSize * 100 / fileSize));
                }
                in.close();
                out.close();
                downloadSize = 0;
                publishProgress(0);
                if (!mStopFlag) {
                    mIsReError = true;
                    url = new URL(mUrl);
                    con = (HttpURLConnection) url.openConnection();
                    con.setConnectTimeout(TIME_OUT);
                    con.setRequestProperty("Accept-Encoding", "identity");
                    in = con.getInputStream();
                    fileOut = new File(CACHE_PATH + Consistent.RE_FILE);
                    out = new FileOutputStream(fileOut);
                    bytes = new byte[1024];
                    fileSize = con.getContentLength();
                    publishProgress(Consistent.CONNECTED);
                    while ((len = in.read(bytes)) != -1) {
                        if (mStopFlag) {
                            con.disconnect();
                            break;
                        }
                        out.write(bytes, 0, len);
                        downloadSize += len;
                        publishProgress((int) (downloadSize * 100 / fileSize));
                    }
                    in.close();
                    out.close();
                    publishProgress(Consistent.MIX_HOSTS);
                    mixHosts();
                }
            } catch (Exception e) {
                e.printStackTrace();
                mStopFlag = true;
                if (mIsReError) {
                    publishProgress(Consistent.CUSTOM_ERROR);
                } else {
                    publishProgress(Consistent.DOWNLOAD_CANCEL);
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(Boolean result) {
            if (mIsKeepScreenOn) {
                ((Activity) mContext).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                Toast.makeText(mContext, mContext.getString(R.string.keep_screen_on_hint_off), Toast.LENGTH_SHORT).show();
            }
            if (!mStopFlag) {
                mMixProgressDialog.cancel();
                InsertClashTaskHelper insertClashTaskHelper = new InsertClashTaskHelper();
                insertClashTaskHelper.insertClashHelper(mContext, mHosts, mCheck, mCheckBox);
            } else {
                CleanCacheHelper cleanCacheHelper = new CleanCacheHelper();
                cleanCacheHelper.cleanHosts(mContext);
            }
        }

        @Override
        protected void onProgressUpdate(Integer... values) {
            if (values[0] == CONNECTED) {
                mProgressDialog.setMessage(mContext.getString(R.string.downloading));
            } else if (values[0] == DOWNLOAD_CANCEL) {
                mProgressDialog.cancel();
            } else if (values[0] == MIX_HOSTS) {
                if (mIsKeepScreenOn) {
                    ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                    Toast.makeText(mContext, mContext.getString(R.string.keep_screen_on_hint_on), Toast.LENGTH_SHORT).show();
                }
                mProgressDialog.cancel();
                mMixProgressDialog = new ProgressDialog(mContext);
                mMixProgressDialog.setMessage(mContext.getString(R.string.mix_hosts));
                mMixProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                mMixProgressDialog.setIndeterminate(true);
                mMixProgressDialog.setCancelable(false);
                mMixProgressDialog.show();
            } else if (values[0] == CUSTOM_ERROR) {
                Toast.makeText(mContext, mContext.getString(R.string.custom_error), Toast.LENGTH_SHORT).show();
                mProgressDialog.cancel();
            } else {
                mProgressDialog.setProgress(values[0]);
            }
        }

        void mixHosts() {
            File file = mContext.getCacheDir();
            final String CACHE_PATH = file.getAbsolutePath();
            List<String> mReClashList = new ArrayList<>();
            try {
                BufferedReader adReader;
                adReader = new BufferedReader(new FileReader(CACHE_PATH + Consistent.HOSTS_FILE));
                String line;
                while ((line = adReader.readLine()) != null) {
                    if (!(line.contains(Consistent.HASH_TAG) || line.equals(""))) {
                        mReClashList.add(line.replace(Consistent.LOCAL_HOST + " ", ""));
                    }
                }
                adReader.close();
                BufferedReader reReader = new BufferedReader(new FileReader(CACHE_PATH + Consistent.RE_FILE));
                FileOutputStream fileOutputStream = new FileOutputStream(CACHE_PATH + Consistent.HOSTS_FILE, true);
                boolean flag = false;
                while ((line = reReader.readLine()) != null) {
                    for (String tmp : mReClashList) {
                        if (line.contains(tmp)) {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag) {
                        fileOutputStream.write((line + "\n").getBytes());
                    } else {
                        flag = false;
                    }
                }
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


package com.lack006.hosts_l.Download;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.Toast;
import com.lack006.hosts_l.Consistent.Consistent;
import com.lack006.hosts_l.CleanCache.CleanCacheHelper;
import com.lack006.hosts_l.Clash.InsertClashTaskHelper;
import com.lack006.hosts_l.R;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import static com.lack006.hosts_l.Consistent.Consistent.CONNECTED;
import static com.lack006.hosts_l.Consistent.Consistent.CUSTOM_ERROR;
import static com.lack006.hosts_l.Consistent.Consistent.DOWNLOAD_CANCEL;
import static com.lack006.hosts_l.Consistent.Consistent.MIX_HOSTS;
import static com.lack006.hosts_l.Consistent.Consistent.TIME_OUT;

/**
 * Created by lack on 2016/12/15.
 * AndroidHosts-LV7
 */
public class CustomDownloadTaskHelper {

    private Context mContext = null;

    private ProgressDialog mProgressDialog = null;

    private ProgressDialog mMixProgressDialog = null;

    private CheckBox mCheckBox = null;

    private String[] mHosts = null;

    private boolean[] mCheck = null;

    private boolean mStopFlag = false;

    private boolean mIsReError = false;

    private boolean mIsKeepScreenOn = false;

    private String mUrl = null;

    public void download(Context context, String url, String[] hosts, boolean[] check, CheckBox checkBox, boolean keepScreenOn) {
        mContext = context;
        mHosts = hosts;
        mCheck = check;
        mCheckBox = checkBox;
        mUrl = url;
        mIsKeepScreenOn = keepScreenOn;
        CleanCacheHelper cleanCacheHelper = new CleanCacheHelper();
        cleanCacheHelper.cleanHosts(mContext);
        mProgressDialog = new ProgressDialog(mContext);
        mProgressDialog.setMessage(mContext.getString(R.string.connecting));
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgress

        mProgressDialog.setCancelable(false);
        mProgressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                mProgressDialog.setProgress(Consistent.DOWNLOAD_CANCEL);
                mStopFlag = true;
            }
        });
        mProgressDialog.show();
        DownloadHostsTask downloadHostsTask = new DownloadHostsTask();
        downloadHostsTask.execute();
    }

    private class DownloadHostsTask extends AsyncTask<Object, Integer, Boolean> {

        @Override
        protected Boolean doInBackground(Object... objects) {
            File file = mContext.getCacheDir();
            final String CACHE_PATH = file.getAbsolutePath();
            URL url;
            long fileSize;
            long downloadSize = 0;
            try {
                url = new URL(mContext.getString(R.string.ad_url));
                HttpURLConnection con = (HttpURLConnection) url.openConnection();
                con.setConnectTimeout(TIME_OUT);
                con.setRequestProperty("Accept-Encoding", "identity");
                InputStream in = con.getInputStream();
                File fileOut = new File(CACHE_PATH + Consistent.HOSTS_FILE);
                FileOutputStream out = new FileOutputStream(fileOut);
                byte[] bytes = new byte[1024];
                int len;
                fileSize = con.getContentLength();
                publishProgress(Consistent.CONNECTED);
                while ((len = in.read(bytes)) != -1) {
                    if (mStopFlag) {
                        con.disconnect();
                        break;
                    }
                    out.write(bytes, 0, len);
                    downloadSize += len;
                    publishProgress((int) (downloadSize * 100 / fileSize));
                }
                in.close();
                out.close();
                downloadSize = 0;
                publishProgress(0);
                if (!mStopFlag) {
                    mIsReError = true;
                    url = new URL(mUrl);
                    con = (HttpURLConnection) url.openConnection();
                    con.setConnectTimeout(TIME_OUT);
                    con.setRequestProperty("Accept-Encoding", "identity");
                    in = con.getInputStream();
                    fileOut = new File(CACHE_PATH + Consistent.RE_FILE);
                    out = new FileOutputStream(fileOut);
                    bytes = new byte[1024];
                    fileSize = con.getContentLength();
                    publishProgress(Consistent.CONNECTED);
                    while ((len = in.read(bytes)) != -1) {
                        if (mStopFlag) {
                            con.disconnect();
                            break;
                        }
                        out.write(bytes, 0, len);
                        downloadSize += len;
                        publishProgress((int) (downloadSize * 100 / fileSize));
                    }
                    in.close();
                    out.close();
                    publishProgress(Consistent.MIX_HOSTS);
                    mixHosts();
                }
            } catch (Exception e) {
                e.printStackTrace();
                mStopFlag = true;
                if (mIsReError) {
                    publishProgress(Consistent.CUSTOM_ERROR);
                } else {
                    publishProgress(Consistent.DOWNLOAD_CANCEL);
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(Boolean result) {
            if (mIsKeepScreenOn) {
                ((Activity) mContext).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                Toast.makeText(mContext, mContext.getString(R.string.keep_screen_on_hint_off), Toast.LENGTH_SHORT).show();
            }
            if (!mStopFlag) {
                mMixProgressDialog.cancel();
                InsertClashTaskHelper insertClashTaskHelper = new InsertClashTaskHelper();
                insertClashTaskHelper.insertClashHelper(mContext, mHosts, mCheck, mCheckBox);
            } else {
                CleanCacheHelper cleanCacheHelper = new CleanCacheHelper();
                cleanCacheHelper.cleanHosts(mContext);
            }
        }

        @Override
        protected void onProgressUpdate(Integer... values) {
            if (values[0] == CONNECTED) {
                mProgressDialog.setMessage(mContext.getString(R.string.downloading));
            } else if (values[0] == DOWNLOAD_CANCEL) {
                mProgressDialog.cancel();
            } else if (values[0] == MIX_HOSTS) {
                if (mIsKeepScreenOn) {
                    ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                    Toast.makeText(mContext, mContext.getString(R.string.keep_screen_on_hint_on), Toast.LENGTH_SHORT).show();
                }
                mProgressDialog.cancel();
                mMixProgressDialog = new ProgressDialog(mContext);
                mMixProgressDialog.setMessage(mContext.getString(R.string.mix_hosts));
                mMixProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                mMixProgressDialog.setIndeterminate(true);
                mMixProgressDialog.setCancelable(false);
                mMixProgressDialog.show();
            } else if (values[0] == CUSTOM_ERROR) {
                Toast.makeText(mContext, mContext.getString(R.string.custom_error), Toast.LENGTH_SHORT).show();
                mProgressDialog.cancel();
            } else {
                mProgressDialog.setProgress(values[0]);
            }
        }

        void mixHosts() {
            File file = mContext.getCacheDir();
            final String CACHE_PATH = file.getAbsolutePath();
            List<String> mReClashList = new ArrayList<>();
            try {
                BufferedReader adReader;
                adReader = new BufferedReader(new FileReader(CACHE_PATH + Consistent.HOSTS_FILE));
                String line;
                while ((line = adReader.readLine()) != null) {
                    if (!(line.contains(Consistent.HASH_TAG) || line.equals(""))) {
                        mReClashList.add(line.replace(Consistent.LOCAL_HOST + " ", ""));
                    }
                }
                adReader.close();
                BufferedReader reReader = new BufferedReader(new FileReader(CACHE_PATH + Consistent.RE_FILE));
                FileOutputStream fileOutputStream = new FileOutputStream(CACHE_PATH + Consistent.HOSTS_FILE, true);
                boolean flag = false;
                while ((line = reReader.readLine()) != null) {
                    for (String tmp : mReClashList) {
                        if (line.contains(tmp)) {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag) {
                        fileOutputStream.write((line + "\n").getBytes());
                    } else {
                        flag = false;
                    }
                }
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


package com.lack006.hosts_l.Download;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.Toast;
import com.lack006.hosts_l.Consistent.Consistent;
import com.lack006.hosts_l.CleanCache.CleanCacheHelper;
import com.lack006.hosts_l.Clash.InsertClashTaskHelper;
import com.lack006.hosts_l.R;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import static com.lack006.hosts_l.Consistent.Consistent.CONNECTED;
import static com.lack006.hosts_l.Consistent.Consistent.CUSTOM_ERROR;
import static com.lack006.hosts_l.Consistent.Consistent.DOWNLOAD_CANCEL;
import static com.lack006.hosts_l.Consistent.Consistent.MIX_HOSTS;
import static com.lack006.hosts_l.Consistent.Consistent.TIME_OUT;

/**
 * Created by lack on 2016/12/15.
 * AndroidHosts-LV7
 */
public class CustomDownloadTaskHelper {

    private Context mContext = null;

    private ProgressDialog mProgressDialog = null;

    private ProgressDialog mMixProgressDialog = null;

    private CheckBox mCheckBox = null;

    private String[] mHosts = null;

    private boolean[] mCheck = null;

    private boolean mStopFlag = false;

    private boolean mIsReError = false;

    private boolean mIsKeepScreenOn = false;

    private String mUrl = null;

    public void download(Context context, String url, String[] hosts, boolean[] check, CheckBox checkBox, boolean keepScreenOn) {
        mContext = context;
        mHosts = hosts;
        mCheck = check;
        mCheckBox = checkBox;
        mUrl = url;
        mIsKeepScreenOn = keepScreenOn;
        CleanCacheHelper cleanCacheHelper = new CleanCacheHelper();
        cleanCacheHelper.cleanHosts(mContext);
        mProgressDialog = new ProgressDialog(mContext);
        mProgressDialog.setMessage(mContext.getString(R.string.connecting));
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setIndeterminate(false);
        mProgressDialog.setCancelable(false);
        mProgressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                mProgressDialog.setProgress(Consistent.DOWNLOAD_CANCEL);
                mStopFlag = true;
            }
        });
        mProgressDialog.show();
        DownloadHostsTask downloadHostsTask = new DownloadHostsTask();
        downloadHostsTask.execute();
    }

    private class DownloadHostsTask extends AsyncTask<Object, Integer, Boolean> {

        @Override
        protected Boolean doInBackground(Object... objects) {
            File file = mContext.getCacheDir();
            final String CACHE_PATH = file.getAbsolutePath();
            URL url;
            long fileSize;
            long downloadSize = 0;
            try {
                url = new URL(mContext.getString(R.string.ad_url));
                HttpURLConnection con = (HttpURLConnection) url.openConnection();
                con.setConnectTimeout(TIME_OUT);
                con.setRequestProperty("Accept-Encoding", "identity");
                InputStream in = con.getInputStream();
                File fileOut = new File(CACHE_PATH + Consistent.HOSTS_FILE);
                FileOutputStream out = new FileOutputStream(fileOut);
                byte[] bytes = new byte[1024];
                int len;
                fileSize = con.getContentLength();
                publishProgress(Consistent.CONNECTED);
                while ((len = in.read(bytes)) != -1) {
                    if (mStopFlag) {
                        con.disconnect();
                        break;
                    }
                    out.write(bytes, 0, len);
                    downloadSize += len;
                    publishProgress((int) (downloadSize * 100 / fileSize));
                }
                in.close();
                out.close();
                downloadSize = 0;
                publishProgress(0);
                if (!mStopFlag) {
                    mIsReError = true;
                    url = new URL(mUrl);
                    con = (HttpURLConnection) url.openConnection();
                    con.setConnectTimeout(TIME_OUT);
                    con.setRequestProperty("Accept-Encoding", "identity");
                    in = con.getInputStream();
                    fileOut = new File(CACHE_PATH + Consistent.RE_FILE);
                    out = new FileOutputStream(fileOut);
                    bytes = new byte[1024];
                    fileSize = con.getContentLength();
                    publishProgress(Consistent.CONNECTED);

                    in.close();
                    out.close();
                    publishProgress(Consistent.MIX_HOSTS);
                    mixHosts();
                }
            } catch (Exception e) {
                e.printStackTrace();
                mStopFlag = true;
                if (mIsReError) {
                    publishProgress(Consistent.CUSTOM_ERROR);
                } else {
                    publishProgress(Consistent.DOWNLOAD_CANCEL);
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(Boolean result) {
            if (mIsKeepScreenOn) {
                ((Activity) mContext).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                Toast.makeText(mContext, mContext.getString(R.string.keep_screen_on_hint_off), Toast.LENGTH_SHORT).show();
            }
            if (!mStopFlag) {
                mMixProgressDialog.cancel();
                InsertClashTaskHelper insertClashTaskHelper = new InsertClashTaskHelper();
                insertClashTaskHelper.insertClashHelper(mContext, mHosts, mCheck, mCheckBox);
            } else {
                CleanCacheHelper cleanCacheHelper = new CleanCacheHelper();
                cleanCacheHelper.cleanHosts(mContext);
            }
        }

        @Override
        protected void onProgressUpdate(Integer... values) {
            if (values[0] == CONNECTED) {
                mProgressDialog.setMessage(mContext.getString(R.string.downloading));
            } else if (values[0] == DOWNLOAD_CANCEL) {
                mProgressDialog.cancel();
            } else if (values[0] == MIX_HOSTS) {
                if (mIsKeepScreenOn) {
                    ((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
                    Toast.makeText(mContext, mContext.getString(R.string.keep_screen_on_hint_on), Toast.LENGTH_SHORT).show();
                }
                mProgressDialog.cancel();
                mMixProgressDialog = new ProgressDialog(mContext);
                mMixProgressDialog.setMessage(mContext.getString(R.string.mix_hosts));
                mMixProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                mMixProgressDialog.setIndeterminate(true);
                mMixProgressDialog.setCancelable(false);
                mMixProgressDialog.show();
            } else if (values[0] == CUSTOM_ERROR) {
                Toast.makeText(mContext, mContext.getString(R.string.custom_error), Toast.LENGTH_SHORT).show();
                mProgressDialog.cancel();
            } else {
                mProgressDialog.setProgress(values[0]);
            }
        }

        void mixHosts() {
            File file = mContext.getCacheDir();
            final String CACHE_PATH = file.getAbsolutePath();
            List<String> mReClashList = new ArrayList<>();
            try {
                BufferedReader adReader;
                adReader = new BufferedReader(new FileReader(CACHE_PATH + Consistent.HOSTS_FILE));
                String line;
                while ((line = adReader.readLine()) != null) {
                    if (!(line.contains(Consistent.HASH_TAG) || line.equals(""))) {
                        mReClashList.add(line.replace(Consistent.LOCAL_HOST + " ", ""));
                    }
                }
                adReader.close();
                BufferedReader reReader = new BufferedReader(new FileReader(CACHE_PATH + Consistent.RE_FILE));
                FileOutputStream fileOutputStream = new FileOutputStream(CACHE_PATH + Consistent.HOSTS_FILE, true);
                boolean flag = false;
                while ((line = reReader.readLine()) != null) {
                    for (String tmp : mReClashList) {
                        if (line.contains(tmp)) {
                            flag = true;
                            break;
                        }
                    }
                    if (!flag) {
                        fileOutputStream.write((line + "\n").getBytes());
                    } else {
                        flag = false;
                    }
                }
                fileOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


/*-
 * #%L
 * Soot - a J*va Optimization Framework
 * %%
 * %%
 * #L%
 */
public class Complex {


/*-
 * #%L
 * Soot - a J*va Optimization Framework
 * %%
 * %%
 * #L%
 */
public class Complex {

    public static void main(String[] args)


/*-
 * #%L
 * Soot - a J*va Optimization Framework
 * %%
 * %%
 * #L%
 */
public class Complex {

    public static void main(String[] args) {
        int[] a = new int[] { 2, 3, 4, 5, 3, 3, 4, 3, 2 };
        int x

        int y = 3;
        int z = 4;
        System.out.println(a[x = y = z]);
    }
}


public void setInputStream(InputStream is);

package jakarta.ws.rs.ext;

import java.io.IOException;
import java.io.InputStream;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MultivaluedMap;

/**
 * Context class used by {@link jakarta.ws.rs.ext.ReaderInterceptor} to intercept calls to (@link
 * jakarta.ws.rs.ext.MessageBodyReader#readFrom}. The getters and setters in this context class correspond to the
 * parameters of the intercepted method.
 *
 * @author Santiago Pericas-Geertsen
 * @author Bill Burke
 * @see ReaderInterceptor
 * @see MessageBodyReader
 * @since 2.0
 */
public interface ReaderInterceptorContext extends InterceptorContext {

    /**
     * Proceed to the next interceptor in the chain. Return the result of the next interceptor invoked. Interceptors MUST
     * explicitly call this method to continue the execution chain; the call to this method in the last interceptor of the
     * chain will invoke the wrapped {@link jakarta.ws.rs.ext.MessageBodyReader#readFrom}.
     *
     * @return result of next interceptor invoked.
     * @throws IOException if an IO error arises or is thrown by the wrapped {@code MessageBodyReader.readFrom} method.
     * @throws jakarta.ws.rs.WebApplicationException thrown by the wrapped {@code MessageBodyReader.readFrom} method.
     */
    public Object proceed() throws IOException, WebApplicationException;

    /**
     * Get the input stream of the object to be read. The JAX-RS runtime is responsible for closing the input stream.
     *
     * @return input stream of the object to be read.
     */
    public InputStream getInputStream();

    /**
     * Set the input stream of the object to be read. For example, by wrapping it with another input stream. The JAX-RS
     * runtime is responsible for closing the input stream that is set.
     *
     * @param is new input stream.
     */

    /**
     * Get mutable map of HTTP headers.
     * <p>
     * Note that while the headers are mutable, a {@link ReaderInterceptor reader interceptor} should typically roll-back
     * any header modifications once the call to {@link #proceed() context.proceed()} returns, to avoid externally visible
     * side-effects of the interceptor invocation.
     * </p>
     *
     * @return map of HTTP headers.
     */
    public MultivaluedMap<String, String> getHeaders();
}


@SuppressWarnings("serial")
    private void createSelectMappedStatement(String mappedStatement, SqlSource sqlSource, final Class<?> resultType)

package com.baomidou.mybatisplus.core.injector;

import com.baomidou.mybatisplus.core.assist.ISqlRunner;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.scripting.LanguageDriver;
import org.apache.ibatis.session.Configuration;
import java.util.ArrayList;
import java.util.Map;

/**
 * SqlRunner 注入器
 *
 * @author hubin
 * @since 2018-04-08
 */
public class SqlRunnerInjector {

    private static final Log logger = LogFactory.getLog(SqlRunnerInjector.class);

    protected Configuration configuration;

    protected LanguageDriver languageDriver;

    public void inject(Configuration configuration) {
        this.configuration = configuration;
        this.languageDriver = configuration.getDefaultScriptingLanguageInstance();
        this.initSelectList();
        this.initSelectObjs();
        this.initInsert();
        this.initUpdate();
        this.initDelete();
        this.initCount();
    }

    /**
     * 是否已经存在MappedStatement
     *
     * @param mappedStatement
     * @return
     */
    private boolean hasMappedStatement(String mappedStatement) {
        return configuration.hasStatement(mappedStatement, false);
    }

    /**
     * 创建查询MappedStatement
     *
     * @param mappedStatement
     * @param sqlSource       执行的sqlSource
     * @param resultType      返回的结果类型
     */

{
        MappedStatement ms = new MappedStatement.Builder(configuration, mappedStatement, sqlSource, SqlCommandType.SELECT).resultMaps(new ArrayList<ResultMap>() {

            {
                add(new ResultMap.Builder(configuration, "defaultResultMap", resultType, new ArrayList<>(0)).build());
            }
        }).build();
        // 缓存
        configuration.addMappedStatement(ms);
    }

    /**
     * 创建一个MappedStatement
     *
     * @param mappedStatement
     * @param sqlSource       执行的sqlSource
     * @param sqlCommandType  执行的sqlCommandType
     */
    @SuppressWarnings("serial")
    private void createUpdateMappedStatement(String mappedStatement, SqlSource sqlSource, SqlCommandType sqlCommandType) {
        MappedStatement ms = new MappedStatement.Builder(configuration, mappedStatement, sqlSource, sqlCommandType).resultMaps(new ArrayList<ResultMap>() {

            {
                add(new ResultMap.Builder(configuration, "defaultResultMap", int.class, new ArrayList<>(0)).build());
            }
        }).build();
        // 缓存
        configuration.addMappedStatement(ms);
    }

    private void initSelectList() {
        if (hasMappedStatement(ISqlRunner.SELECT_LIST)) {
            logger.warn("MappedStatement 'SqlRunner.SelectList' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createSelectMappedStatement(ISqlRunner.SELECT_LIST, sqlSource, Map.class);
    }

    private void initSelectObjs() {
        if (hasMappedStatement(ISqlRunner.SELECT_OBJS)) {
            logger.warn("MappedStatement 'SqlRunner.SelectObjs' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Object.class);
        createSelectMappedStatement(ISqlRunner.SELECT_OBJS, sqlSource, Object.class);
    }

    private void initCount() {
        if (hasMappedStatement(ISqlRunner.COUNT)) {
            logger.warn("MappedStatement 'SqlRunner.Count' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createSelectMappedStatement(ISqlRunner.COUNT, sqlSource, Long.class);
    }

    private void initInsert() {
        if (hasMappedStatement(ISqlRunner.INSERT)) {
            logger.warn("MappedStatement 'SqlRunner.Insert' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.INSERT, sqlSource, SqlCommandType.INSERT);
    }

    private void initUpdate() {
        if (hasMappedStatement(ISqlRunner.UPDATE)) {
            logger.warn("MappedStatement 'SqlRunner.Update' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.UPDATE, sqlSource, SqlCommandType.UPDATE);
    }

    private void initDelete() {
        if (hasMappedStatement(ISqlRunner.DELETE)) {
            logger.warn("MappedStatement 'SqlRunner.Delete' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.DELETE, sqlSource, SqlCommandType.DELETE);
    }
}


{
        MappedStatement ms = new MappedStatement.Builder(configuration, mappedStatement, sqlSource, sqlCommandType).resultMaps(new ArrayList<ResultMap>() {

            {
                add(new ResultMap.Builder(configuration, "defaultResultMap", int.class, new ArrayList<>(0)).build());
            }
        }).build();
        // 缓存
        configuration.addMappedStatement(ms);
    }

package com.baomidou.mybatisplus.core.injector;

import com.baomidou.mybatisplus.core.assist.ISqlRunner;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.scripting.LanguageDriver;
import org.apache.ibatis.session.Configuration;
import java.util.ArrayList;
import java.util.Map;

/**
 * SqlRunner 注入器
 *
 * @author hubin
 * @since 2018-04-08
 */
public class SqlRunnerInjector {

    private static final Log logger = LogFactory.getLog(SqlRunnerInjector.class);

    protected Configuration configuration;

    protected LanguageDriver languageDriver;

    public void inject(Configuration configuration) {
        this.configuration = configuration;
        this.languageDriver = configuration.getDefaultScriptingLanguageInstance();
        this.initSelectList();
        this.initSelectObjs();
        this.initInsert();
        this.initUpdate();
        this.initDelete();
        this.initCount();
    }

    /**
     * 是否已经存在MappedStatement
     *
     * @param mappedStatement
     * @return
     */
    private boolean hasMappedStatement(String mappedStatement) {
        return configuration.hasStatement(mappedStatement, false);
    }

    /**
     * 创建查询MappedStatement
     *
     * @param mappedStatement
     * @param sqlSource       执行的sqlSource
     * @param resultType      返回的结果类型
     */
    @SuppressWarnings("serial")
    private void createSelectMappedStatement(String mappedStatement, SqlSource sqlSource, final Class<?> resultType) {
        MappedStatement ms = new MappedStatement.Builder(configuration, mappedStatement, sqlSource, SqlCommandType.SELECT).resultMaps(new ArrayList<ResultMap>() {

            {
                add(new ResultMap.Builder(configuration, "defaultResultMap", resultType, new ArrayList<>(0)).build());
            }
        }).build();
        // 缓存
        configuration.addMappedStatement(ms);
    }

    /**
     * 创建一个MappedStatement
     *
     * @param mappedStatement
     * @param sqlSource       执行的sqlSource
     * @param sqlCommandType  执行的sqlCommandType
     */
    @SuppressWarnings("serial")
    private void createUpdateMappedStatement(String mappedStatement, SqlSource sqlSource, SqlCommandType sqlCommandType)

    private void initSelectList() {
        if (hasMappedStatement(ISqlRunner.SELECT_LIST)) {
            logger.warn("MappedStatement 'SqlRunner.SelectList' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createSelectMappedStatement(ISqlRunner.SELECT_LIST, sqlSource, Map.class);
    }

    private void initSelectObjs() {
        if (hasMappedStatement(ISqlRunner.SELECT_OBJS)) {
            logger.warn("MappedStatement 'SqlRunner.SelectObjs' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Object.class);
        createSelectMappedStatement(ISqlRunner.SELECT_OBJS, sqlSource, Object.class);
    }

    private void initCount() {
        if (hasMappedStatement(ISqlRunner.COUNT)) {
            logger.warn("MappedStatement 'SqlRunner.Count' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createSelectMappedStatement(ISqlRunner.COUNT, sqlSource, Long.class);
    }

    private void initInsert() {
        if (hasMappedStatement(ISqlRunner.INSERT)) {
            logger.warn("MappedStatement 'SqlRunner.Insert' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.INSERT, sqlSource, SqlCommandType.INSERT);
    }

    private void initUpdate() {
        if (hasMappedStatement(ISqlRunner.UPDATE)) {
            logger.warn("MappedStatement 'SqlRunner.Update' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.UPDATE, sqlSource, SqlCommandType.UPDATE);
    }

    private void initDelete() {
        if (hasMappedStatement(ISqlRunner.DELETE)) {
            logger.warn("MappedStatement 'SqlRunner.Delete' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.DELETE, sqlSource, SqlCommandType.DELETE);
    }
}


package com.baomidou.mybatisplus.core.injector;

import com.baomidou.mybatisplus.core.assist.ISqlRunner;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.scripting.LanguageDriver;
import org.apache.ibatis.session.Configuration;
import java.util.ArrayList;
import java.util.Map;

/**
 * SqlRunner 注入器
 *
 * @author hubin
 * @since 2018-04-08
 */
public class SqlRunnerInjector {

    private static final Log logger = LogFactory.getLog(SqlRunnerInjector.class);

    protected Configuration configuration;

    protected LanguageDriver languageDriver;

    public void inject(Configuration configuration) {
        this.configuration = configuration;
        this.languageDriver = configuration.getDefaultScriptingLanguageInstance();
        this.initSelectList();
        this.initSelectObjs();
        this.initInsert();
        this.initUpdate();
        this.initDelete();
        this.initCount();
    }

    /**
     * 是否已经存在MappedStatement
     *
     * @param mappedStatement
     * @return
     */
    private boolean hasMappedStatement(String mappedStatement) {
        return configuration.hasStatement(mappedStatement, false);
    }

    /**
     * 创建查询MappedStatement
     *
     * @param mappedStatement
     * @param sqlSource       执行的sqlSource
     * @param resultType      返回的结果类型
     */
    @SuppressWarnings("serial")
    private void createSelectMappedStatement(String mappedStatement, SqlSource sqlSource, final Class<?> resultType) {
        MappedStatement ms = new MappedStatement.Builder(configuration, mappedStatement, sqlSource, SqlCommandType.SELECT).resultMaps(new ArrayList<ResultMap>() {

            {
                add(new ResultMap.Builder(configuration, "defaultResultMap", resultType, new ArrayList<>(0)).build());
            }
        }).build();
        // 缓存
        configuration.addMapp

    }

    /**
     * 创建一个MappedStatement
     *
     * @param mappedStatement
     * @param sqlSource       执行的sqlSource
     * @param sqlCommandType  执行的sqlCommandType
     */
    @SuppressWarnings("serial")
    private void createUpdateMappedStatement(String mappedStatement, SqlSource sqlSource, SqlCommandType sqlCommandType) {
        MappedStatement ms = new MappedStatement.Builder(configuration, mappedStatement, sqlSource, sqlCommandType).resultMaps(new ArrayList<ResultMap>() {

            {
                add(new ResultMap.Builder(configuration, "defaultResultMap", int.class, new ArrayList<>(0)).build());
            }
        }).build();
        // 缓存
        configuration.addMappedStatement(ms);
    }

    private void initSelectList() {
        if (hasMappedStatement(ISqlRunner.SELECT_LIST)) {
            logger.warn("MappedStatement 'SqlRunner.SelectList' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createSelectMappedStatement(ISqlRunner.SELECT_LIST, sqlSource, Map.class);
    }

    private void initSelectObjs() {
        if (hasMappedStatement(ISqlRunner.SELECT_OBJS)) {
            logger.warn("MappedStatement 'SqlRunner.SelectObjs' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Object.class);
        createSelectMappedStatement(ISqlRunner.SELECT_OBJS, sqlSource, Object.class);
    }

    private void initCount() {
        if (hasMappedStatement(ISqlRunner.COUNT)) {
            logger.warn("MappedStatement 'SqlRunner.Count' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createSelectMappedStatement(ISqlRunner.COUNT, sqlSource, Long.class);
    }

    private void initInsert() {
        if (hasMappedStatement(ISqlRunner.INSERT)) {
            logger.warn("MappedStatement 'SqlRunner.Insert' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.INSERT, sqlSource, SqlCommandType.INSERT);
    }

    private void initUpdate() {
        if (hasMappedStatement(ISqlRunner.UPDATE)) {
            logger.warn("MappedStatement 'SqlRunner.Update' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.UPDATE, sqlSource, SqlCommandType.UPDATE);
    }

    private void initDelete() {
        if (hasMappedStatement(ISqlRunner.DELETE)) {
            logger.warn("MappedStatement 'SqlRunner.Delete' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.DELETE, sqlSource, SqlCommandType.DELETE);
    }
}


private boolean hasMappedStatement(String mappedStatement) {
        return configuration.hasStatement(mappedStatement, false);
    }

package com.baomidou.mybatisplus.core.injector;

import com.baomidou.mybatisplus.core.assist.ISqlRunner;
import org.apache.ibatis.logging.Log;
import org.apache.ibatis.logging.LogFactory;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ResultMap;
import org.apache.ibatis.mapping.SqlCommandType;
import org.apache.ibatis.mapping.SqlSource;
import org.apache.ibatis.scripting.LanguageDriver;
import org.apache.ibatis.session.Configuration;
import java.util.ArrayList;
import java.util.Map;

/**
 * SqlRunner 注入器
 *
 * @author hubin
 * @since 2018-04-08
 */
public class SqlRunnerInjector {

    private static final Log logger = LogFactory.getLog(SqlRunnerInjector.class);

    protected Configuration configuration;

    protected LanguageDriver languageDriver;

    public void inject(Configuration configuration) {
        this.configuration = configuration;
        this.languageDriver = configuration.getDefaultScriptingLanguageInstance();
        this.initSelectList();
        this.initSelectObjs();
        this.initInsert();
        this.initUpdate();
        this.initDelete();
        this.initCount();
    }

    /**
     * 是否已经存在MappedStatement
     *
     * @param mappedStatement
     * @return
     */

    /**
     * 创建查询MappedStatement
     *
     * @param mappedStatement
     * @param sqlSource       执行的sqlSource
     * @param resultType      返回的结果类型
     */
    @SuppressWarnings("serial")
    private void createSelectMappedStatement(String mappedStatement, SqlSource sqlSource, final Class<?> resultType) {
        MappedStatement ms = new MappedStatement.Builder(configuration, mappedStatement, sqlSource, SqlCommandType.SELECT).resultMaps(new ArrayList<ResultMap>() {

            {
                add(new ResultMap.Builder(configuration, "defaultResultMap", resultType, new ArrayList<>(0)).build());
            }
        }).build();
        // 缓存
        configuration.addMappedStatement(ms);
    }

    /**
     * 创建一个MappedStatement
     *
     * @param mappedStatement
     * @param sqlSource       执行的sqlSource
     * @param sqlCommandType  执行的sqlCommandType
     */
    @SuppressWarnings("serial")
    private void createUpdateMappedStatement(String mappedStatement, SqlSource sqlSource, SqlCommandType sqlCommandType) {
        MappedStatement ms = new MappedStatement.Builder(configuration, mappedStatement, sqlSource, sqlCommandType).resultMaps(new ArrayList<ResultMap>() {

            {
                add(new ResultMap.Builder(configuration, "defaultResultMap", int.class, new ArrayList<>(0)).build());
            }
        }).build();
        // 缓存
        configuration.addMappedStatement(ms);
    }

    private void initSelectList() {
        if (hasMappedStatement(ISqlRunner.SELECT_LIST)) {
            logger.warn("MappedStatement 'SqlRunner.SelectList' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createSelectMappedStatement(ISqlRunner.SELECT_LIST, sqlSource, Map.class);
    }

    private void initSelectObjs() {
        if (hasMappedStatement(ISqlRunner.SELECT_OBJS)) {
            logger.warn("MappedStatement 'SqlRunner.SelectObjs' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Object.class);
        createSelectMappedStatement(ISqlRunner.SELECT_OBJS, sqlSource, Object.class);
    }

    private void initCount() {
        if (hasMappedStatement(ISqlRunner.COUNT)) {
            logger.warn("MappedStatement 'SqlRunner.Count' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createSelectMappedStatement(ISqlRunner.COUNT, sqlSource, Long.class);
    }

    private void initInsert() {
        if (hasMappedStatement(ISqlRunner.INSERT)) {
            logger.warn("MappedStatement 'SqlRunner.Insert' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.INSERT, sqlSource, SqlCommandType.INSERT);
    }

    private void initUpdate() {
        if (hasMappedStatement(ISqlRunner.UPDATE)) {
            logger.warn("MappedStatement 'SqlRunner.Update' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.UPDATE, sqlSource, SqlCommandType.UPDATE);
    }

    private void initDelete() {
        if (hasMappedStatement(ISqlRunner.DELETE)) {
            logger.warn("MappedStatement 'SqlRunner.Delete' Already Exists");
            return;
        }
        SqlSource sqlSource = languageDriver.createSqlSource(configuration, ISqlRunner.SQL_SCRIPT, Map.class);
        createUpdateMappedStatement(ISqlRunner.DELETE, sqlSource, SqlCommandType.DELETE);
    }
}


public String redact(String key, String property)

package com.flightstats.hub.util;

import java.util.Arrays;
import java.util.List;

public class SecretFilter {

    private final static String redacted = "[REDACTED]";

    private final static List<String> matchers = Arrays.asList("app_key", "api_key", "password");

{
        boolean shouldRedact = matchers.stream().anyMatch(key::contains);
        return shouldRedact ? redacted : property;
    }
}


{
        boolean shouldRedact = matchers.stream().anyMatch(key::contains);
        return shouldRedact ? redacted : property;
    }

package com.flightstats.hub.util;

import java.util.Arrays;
import java.util.List;

public class SecretFilter {

    private final static String redacted = "[REDACTED]";

    private final static List<String> matchers = Arrays.asList("app_key", "api_key", "password");

    public String redact(String key, String property)


package com.flightstats.hub.util;

import java.util.Arrays;
import java.util.List;

public class SecretFilter {

    private final static String redacted = "[REDACTED]";

    private final static List<String> matchers = Arrays.asList("app_key", "api_key", "password");

    public String redact(String key, String property) {
        boolean shouldRedact = ma

        return shouldRedact ? redacted : property;
    }
}


public static InputStream getRawHistogram()

package org.graalvm.visualvm.lib.jfluid.server.system;

import java.io.InputStream;

/**
 * @author Tomas Hurka
 */
public class Histogram {

    public static boolean isAvailable() {
        return false;
    }

    public static boolean initialize(boolean jdk9) {
        return false;
    }


package org.graalvm.visualvm.lib.jfluid.server.system;

import java.io.InputStream;

/**
 * @author Tomas Hurka
 */
public class Histogram {

    public static boolean isAvailable() {
        return false;
    }

    public static boolean initialize(boolean jdk9) {
        return false;
    }

    public static InputStream getRawHistogram()


package org.graalvm.visualvm.lib.jfluid.server.system;

import java.io.InputStream;

/**
 * @author Tomas Hurka
 */
public class Histogram {

    public static boolean isAvailable() {
        return false;
    }

    public static boolean initialize(boolean jdk9) {
        return false;
    }

    public static InputStream getRawHistogram() {
        ret