switch(column.type().baseType()) {
                case DECIMAL:
                    return handleDecimal((BigDecimal) value);
                case BYTES:
                    return handleBytes((ByteBuffer) value);
                case TIME:
                    return handleTime((Time) value);
                case DATE:
                    return handleDate((Date) value);
                case TIMESTAMP:
                    return handleTimestamp((Timestamp) value);
                default:
                    return value;
            }
        }

package io.confluent.ksql.serde.delimited;

import io.confluent.ksql.schema.ksql.PersistenceSchema;
import io.confluent.ksql.schema.ksql.SimpleColumn;
import io.confluent.ksql.serde.SerdeUtils;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Base64;
import java.util.Base64.Encoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Serializer;

class KsqlDelimitedSerializer implements Serializer<List<?>> {

    private static Encoder BASE64_ENCODER = Base64.getEncoder();

    private final PersistenceSchema schema;

    private final CSVFormat csvFormat;

    KsqlDelimitedSerializer(final PersistenceSchema schema, final CSVFormat csvFormat) {
        this.schema = Objects.requireNonNull(schema, "schema");
        this.csvFormat = Objects.requireNonNull(csvFormat, "csvFormat");
    }

    @Override
    public void configure(final Map<String, ?> map, final boolean b) {
    }

    @Override
    public byte[] serialize(final String topic, final List<?> data) {
        if (data == null) {
            return null;
        }
        try {
            final StringWriter stringWriter = new StringWriter();
            final CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
            csvPrinter.printRecord(() -> new FieldIterator(data, schema));
            final String result = stringWriter.toString();
            return result.substring(0, result.length() - 2).getBytes(StandardCharsets.UTF_8);
        } catch (final Exception e) {
            throw new SerializationException("Error serializing CSV message", e);
        }
    }

    @Override
    public void close() {
    }

    private static class FieldIterator implements Iterator<Object> {

        private final Iterator<?> dataIt;

        private final Iterator<SimpleColumn> columnIt;

        FieldIterator(final List<?> data, final PersistenceSchema schema) {
            this.dataIt = data.iterator();
            this.columnIt = schema.columns().iterator();
        }

        @Override
        public boolean hasNext() {
            return columnIt.hasNext();
        }

        @Override
        public Object next() {
            final Object value = dataIt.next();
            final SimpleColumn column = columnIt.next();

        private static String handleBytes(final ByteBuffer value) {
            // Return base64 encoding
            return value == null ? null : BASE64_ENCODER.encodeToString(value.array());
        }

        private static Integer handleTime(final Time value) {
            // Return milliseconds
            return value == null ? null : (int) value.getTime();
        }

        private static Integer handleDate(final Date value) {
            // Return epoch days
            return value == null ? null : SerdeUtils.toEpochDays(value);
        }

        private static Long handleTimestamp(final Timestamp value) {
            // Return milliseconds
            return value == null ? null : value.getTime();
        }

        private static String handleDecimal(final BigDecimal value) {
            // Avoid scientific notation for now:
            return value.toPlainString();
        }
    }
}


package io.confluent.ksql.serde.delimited;

import io.confluent.ksql.schema.ksql.PersistenceSchema;
import io.confluent.ksql.schema.ksql.SimpleColumn;
import io.confluent.ksql.serde.SerdeUtils;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Base64;
import java.util.Base64.Encoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Serializer;

class KsqlDelimitedSerializer implements Serializer<List<?>> {

    private static Encoder BASE64_ENCODER = Base64.getEncoder();

    private final PersistenceSchema schema;

    private final CSVFormat csvFormat;

    KsqlDelimitedSerializer(final PersistenceSchema schema, final CSVFormat csvFormat) {
        this.schema = Objects.requireNonNull(schema, "schema");
        this.csvFormat = Objects.requireNonNull(csvFormat, "csvFormat");
    }

    @Override
    public void configure(final Map<String, ?> map, final boolean b) {
    }

    @Override
    public byte[] serialize(final String topic, final List<?> data) {
        if (data == null) {
            return null;
        }
        try {
            final StringWriter stringWriter = new StringWriter();
            final CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
            csvPrinter.printRecord(() -> new FieldIterator(data, schema));
            final String result = stringWriter.toString();
            return result.substring(0, result.length() - 2).getBytes(StandardCharsets.UTF_8);
        } catch (final Exception e) {
            throw new SerializationException("Error serializing CSV message", e);
        }
    }

    @Override
    public void close() {
    }

    private static class FieldIterator implements Iterator<Object> {

        private final Iterator<?> dataIt;

        private final Iterator<SimpleColumn> columnIt;

        FieldIterator(final List<?> data, final PersistenceSchema schema) {
            this.dataIt = data.iterator();
            this.columnIt = schema.columns().iterator();
        }

        @Override
        public boolean hasNext() {
            return columnIt.hasNext();
        }

        @Override
        public Object next() {
            final Object value = dataIt.next();
            final SimpleColumn column = columnIt.next

            switch(column.type().baseType()) {
                case DECIMAL:
                    return handleDecimal((BigDecimal) value);
                case BYTES:
                    return handleBytes((ByteBuffer) value);
                case TIME:
                    return handleTime((Time) value);
                case DATE:
                    return handleDate((Date) value);
                case TIMESTAMP:
                    return handleTimestamp((Timestamp) value);
                default:
                    return value;
            }
        }

        private static String handleBytes(final ByteBuffer value) {
            // Return base64 encoding
            return value == null ? null : BASE64_ENCODER.encodeToString(value.array());
        }

        private static Integer handleTime(final Time value) {
            // Return milliseconds
            return value == null ? null : (int) value.getTime();
        }

        private static Integer handleDate(final Date value) {
            // Return epoch days
            return value == null ? null : SerdeUtils.toEpochDays(value);
        }

        private static Long handleTimestamp(final Timestamp value) {
            // Return milliseconds
            return value == null ? null : value.getTime();
        }

        private static String handleDecimal(final BigDecimal value) {
            // Avoid scientific notation for now:
            return value.toPlainString();
        }
    }
}


if (data == null) {
            return null;
        }

package io.confluent.ksql.serde.delimited;

import io.confluent.ksql.schema.ksql.PersistenceSchema;
import io.confluent.ksql.schema.ksql.SimpleColumn;
import io.confluent.ksql.serde.SerdeUtils;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Base64;
import java.util.Base64.Encoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Serializer;

class KsqlDelimitedSerializer implements Serializer<List<?>> {

    private static Encoder BASE64_ENCODER = Base64.getEncoder();

    private final PersistenceSchema schema;

    private final CSVFormat csvFormat;

    KsqlDelimitedSerializer(final PersistenceSchema schema, final CSVFormat csvFormat) {
        this.schema = Objects.requireNonNull(schema, "schema");
        this.csvFormat = Objects.requireNonNull(csvFormat, "csvFormat");
    }

    @Override
    public void configure(final Map<String, ?> map, final boolean b) {
    }

    @Override
    public byte[] serialize(final String topic, final List<?> data) {

        try {
            final StringWriter stringWriter = new StringWriter();
            final CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
            csvPrinter.printRecord(() -> new FieldIterator(data, schema));
            final String result = stringWriter.toString();
            return result.substring(0, result.length() - 2).getBytes(StandardCharsets.UTF_8);
        } catch (final Exception e) {
            throw new SerializationException("Error serializing CSV message", e);
        }
    }

    @Override
    public void close() {
    }

    private static class FieldIterator implements Iterator<Object> {

        private final Iterator<?> dataIt;

        private final Iterator<SimpleColumn> columnIt;

        FieldIterator(final List<?> data, final PersistenceSchema schema) {
            this.dataIt = data.iterator();
            this.columnIt = schema.columns().iterator();
        }

        @Override
        public boolean hasNext() {
            return columnIt.hasNext();
        }

        @Override
        public Object next() {
            final Object value = dataIt.next();
            final SimpleColumn column = columnIt.next();
            switch(column.type().baseType()) {
                case DECIMAL:
                    return handleDecimal((BigDecimal) value);
                case BYTES:
                    return handleBytes((ByteBuffer) value);
                case TIME:
                    return handleTime((Time) value);
                case DATE:
                    return handleDate((Date) value);
                case TIMESTAMP:
                    return handleTimestamp((Timestamp) value);
                default:
                    return value;
            }
        }

        private static String handleBytes(final ByteBuffer value) {
            // Return base64 encoding
            return value == null ? null : BASE64_ENCODER.encodeToString(value.array());
        }

        private static Integer handleTime(final Time value) {
            // Return milliseconds
            return value == null ? null : (int) value.getTime();
        }

        private static Integer handleDate(final Date value) {
            // Return epoch days
            return value == null ? null : SerdeUtils.toEpochDays(value);
        }

        private static Long handleTimestamp(final Timestamp value) {
            // Return milliseconds
            return value == null ? null : value.getTime();
        }

        private static String handleDecimal(final BigDecimal value) {
            // Avoid scientific notation for now:
            return value.toPlainString();
        }
    }
}


package io.confluent.ksql.serde.delimited;

import io.confluent.ksql.schema.ksql.PersistenceSchema;
import io.confluent.ksql.schema.ksql.SimpleColumn;
import io.confluent.ksql.serde.SerdeUtils;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Base64;
import java.util.Base64.Encoder;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.serialization.Serializer;

class KsqlDelimitedSerializer implements Serializer<List<?>> {

    private static Encoder BASE64_ENCODER = Base64.getEncoder();

    private final PersistenceSchema schema;

    private final CSVFormat csvFormat;

    KsqlDelimitedSerializer(final PersistenceSchema schema, final CSVFormat csvFormat) {
        this.schema = Objects.requireNonNull(schema, "schema");
        this.csvFormat = Objects.requireNonNull(csvFormat, "csvFormat");
    }

    @Override
    public void configure(final Map<String, ?> map, final boolean b) {
    }

    @Override
    public byte[] serialize(final String topic, final List<?> data) {
        if (data == null) {
            return null;
        }
        try {
            final StringWriter stringWriter = new StringWriter();
            final CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
            csvPrinter.printRecord(() -> new FieldIterator(data, schema));
            final String result = stringWriter.toString();
            return result.substring(0, result.length() - 2).getBytes(StandardCharsets.UTF_8);
        } catch (final Exception e) {
            throw new SerializationException("Error serializing CSV message", e);
        }
    }

    @Override
    public void close() {
    }

    private static class FieldIterator implements Iterator<Object> {

        private final Iterator<?> dataIt;

        private final Iterator<SimpleColumn> columnIt;

        FieldIterator(final List<?> data, final PersistenceSchema schema) {
            this.dataIt = data.iterator();
            this.columnIt = schema.columns().iterator();
        }

        @Override
        public boolean hasNext() {
            return columnIt.hasNext();
        }

        @Override
        public Object next() {
            final Object value = dataIt.next();
            final SimpleColumn column = columnIt.next();
            switch(column.type().baseType()) {
                case DECIMAL:
                    return handleDecimal((BigDecimal) value);
                case BYTES:
                    return handleBytes((ByteBuffer) value);
                case TIME:
                    return handleTime((Time) value);
                case DATE:
                    return handleDate((Date) value);
                case TIMESTAMP:
                    return handleTimestamp((Timestamp) value);
                default:
                    return value;
            }
        }

        private static String handleBytes(final ByteBuffer value) {
            // Return base64 encoding
            return value == null ? null : BASE64_ENCODER.encodeToString(value.array());
        }

        private static Integer handleTime(final Time value) {
            // Return milliseconds
            return value == null ? null : (int) value.getTime();
        }

 private static Integer handleDate(final Date value) {
            // Return epoch days
            return value == null ? null : SerdeUtils.toEpochDays(value);
        }

        private static Long handleTimestamp(final Timestamp value) {
            // Return milliseconds
            return value == null ? null : value.getTime();
        }

        private static String handleDecimal(final BigDecimal value) {
            // Avoid scientific notation for now:
            return value.toPlainString();
        }
    }
}


/*
 * and other copyright owners as documented in the project's IP log.
 *
 *
 * All rights reserved.
 *
 */
package org.eclipse.jgit.util;

import static org.eclipse.jgit.util.RelativeDateFormatter.DAY_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.HOUR_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.MINUTE_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.SECOND_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.YEAR_IN_MILLIS;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.eclipse.jgit.junit.MockSystemReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RelativeDateFormatterTest {

    @Before
    public void setUp() {
        SystemReader.setInstance(new MockSystemReader());
    }

    @After
    public void tearDown() {
        SystemReader.setInstance(null);
    }

    private static void assertFormat(long ageFromNow, long timeUnit, String expectedFormat) {
        Date d = new Date(SystemReader.getInstance().getCurrentTime() - ageFromNow * timeUnit);
        String s = RelativeDateFormatter.format(d);
        assertEquals(expectedFormat, s);
    }

    @Test
    public void testFuture() {
        assertFormat(-100, YEAR_IN_MILLIS, "in the future");
        assertFormat(-1, SECOND_IN_MILLIS, "in the future");
    }

    @Test
    public void testFormatSeconds() {
        assertFormat(1, SECOND_IN_MILLIS, "1 seconds ago");
        assertFormat(89, SECOND_IN_MILLIS, "89 seconds ago");
    }

    @Test
    public void testFormatMinutes() {
        assertFormat(90, SECOND_IN_MILLIS, "2 minutes ago");
        assertFormat(3, MINUTE_IN_MILLIS, "3 minutes ago");
        assertFormat(60, MINUTE_IN_MILLIS, "60 minutes ago");
        assertFormat(89, MINUTE_IN_MILLIS, "89 minutes ago");
    }

    @Test
    public void testFormatHours() {
        assertFormat(90, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(149, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(35, HOUR_IN_MILLIS, "35 hours ago");
    }

    @Test
    public void testFormatDays() {
        assertFormat(36, HOUR_IN_MILLIS, "2 days ago");
        assertFormat(13, DAY_IN_MILLIS, "13 days ago");
    }

    @Test
    public void testFormatWeeks() {
        assertFormat(14, DAY_IN_MILLIS, "2 weeks ago");
        assertFormat(69, DAY_IN_MILLIS, "10 weeks ago");
    }

    @Test
    public void testFormatMonths() {
        assertFormat(70, DAY_IN_MILLIS, "2 months ago");
        assertFormat(75, DAY_IN_MILLIS, "3 months ago");
        assertFormat(364, DAY_IN_MILLIS, "12 months ago");
    }

    @Test
    public void testFormatYearsMonths() {
        assertFormat(366, DAY_IN_MILLIS, "1 year ago");
        assertFormat(380, DAY_IN_MILLIS, "1 year, 1 month ago");
        assertFormat(410, DAY_IN_MILLIS, "1 year, 2 months ago");
        assertFormat(2, YEAR_IN_MILLIS, "2 years ago");
        assertFormat(1824, DAY_IN_MILLIS, "4 years, 12 months ago");
    }

{
        assertFormat(5, YEAR_IN_MILLIS, "5 years ago");
        assertFormat(60, YEAR_IN_MILLIS, "60 years ago");
    }
}


{
        assertFormat(90, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(149, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(35, HOUR_IN_MILLIS, "35 hours ago");
    }

/*
 * and other copyright owners as documented in the project's IP log.
 *
 *
 * All rights reserved.
 *
 */
package org.eclipse.jgit.util;

import static org.eclipse.jgit.util.RelativeDateFormatter.DAY_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.HOUR_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.MINUTE_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.SECOND_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.YEAR_IN_MILLIS;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.eclipse.jgit.junit.MockSystemReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RelativeDateFormatterTest {

    @Before
    public void setUp() {
        SystemReader.setInstance(new MockSystemReader());
    }

    @After
    public void tearDown() {
        SystemReader.setInstance(null);
    }

    private static void assertFormat(long ageFromNow, long timeUnit, String expectedFormat) {
        Date d = new Date(SystemReader.getInstance().getCurrentTime() - ageFromNow * timeUnit);
        String s = RelativeDateFormatter.format(d);
        assertEquals(expectedFormat, s);
    }

    @Test
    public void testFuture() {
        assertFormat(-100, YEAR_IN_MILLIS, "in the future");
        assertFormat(-1, SECOND_IN_MILLIS, "in the future");
    }

    @Test
    public void testFormatSeconds() {
        assertFormat(1, SECOND_IN_MILLIS, "1 seconds ago");
        assertFormat(89, SECOND_IN_MILLIS, "89 seconds ago");
    }

    @Test
    public void testFormatMinutes() {
        assertFormat(90, SECOND_IN_MILLIS, "2 minutes ago");
        assertFormat(3, MINUTE_IN_MILLIS, "3 minutes ago");
        assertFormat(60, MINUTE_IN_MILLIS, "60 minutes ago");
        assertFormat(89, MINUTE_IN_MILLIS, "89 minutes ago");
    }

    @Test
    public void testFormatHours()

    @Test
    public void testFormatDays() {
        assertFormat(36, HOUR_IN_MILLIS, "2 days ago");
        assertFormat(13, DAY_IN_MILLIS, "13 days ago");
    }

    @Test
    public void testFormatWeeks() {
        assertFormat(14, DAY_IN_MILLIS, "2 weeks ago");
        assertFormat(69, DAY_IN_MILLIS, "10 weeks ago");
    }

    @Test
    public void testFormatMonths() {
        assertFormat(70, DAY_IN_MILLIS, "2 months ago");
        assertFormat(75, DAY_IN_MILLIS, "3 months ago");
        assertFormat(364, DAY_IN_MILLIS, "12 months ago");
    }

    @Test
    public void testFormatYearsMonths() {
        assertFormat(366, DAY_IN_MILLIS, "1 year ago");
        assertFormat(380, DAY_IN_MILLIS, "1 year, 1 month ago");
        assertFormat(410, DAY_IN_MILLIS, "1 year, 2 months ago");
        assertFormat(2, YEAR_IN_MILLIS, "2 years ago");
        assertFormat(1824, DAY_IN_MILLIS, "4 years, 12 months ago");
    }

    @Test
    public void testFormatYears() {
        assertFormat(5, YEAR_IN_MILLIS, "5 years ago");
        assertFormat(60, YEAR_IN_MILLIS, "60 years ago");
    }
}


        assertFormat(366, DAY_IN_MILLIS, "1 year ago");
        assertFormat(380, DAY_IN_MILLIS, "1 year, 1 month ago");

/*
 * and other copyright owners as documented in the project's IP log.
 *
 *
 * All rights reserved.
 *
 */
package org.eclipse.jgit.util;

import static org.eclipse.jgit.util.RelativeDateFormatter.DAY_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.HOUR_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.MINUTE_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.SECOND_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.YEAR_IN_MILLIS;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.eclipse.jgit.junit.MockSystemReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RelativeDateFormatterTest {

    @Before
    public void setUp() {
        SystemReader.setInstance(new MockSystemReader());
    }

    @After
    public void tearDown() {
        SystemReader.setInstance(null);
    }

    private static void assertFormat(long ageFromNow, long timeUnit, String expectedFormat) {
        Date d = new Date(SystemReader.getInstance().getCurrentTime() - ageFromNow * timeUnit);
        String s = RelativeDateFormatter.format(d);
        assertEquals(expectedFormat, s);
    }

    @Test
    public void testFuture() {
        assertFormat(-100, YEAR_IN_MILLIS, "in the future");
        assertFormat(-1, SECOND_IN_MILLIS, "in the future");
    }

    @Test
    public void testFormatSeconds() {
        assertFormat(1, SECOND_IN_MILLIS, "1 seconds ago");
        assertFormat(89, SECOND_IN_MILLIS, "89 seconds ago");
    }

    @Test
    public void testFormatMinutes() {
        assertFormat(90, SECOND_IN_MILLIS, "2 minutes ago");
        assertFormat(3, MINUTE_IN_MILLIS, "3 minutes ago");
        assertFormat(60, MINUTE_IN_MILLIS, "60 minutes ago");
        assertFormat(89, MINUTE_IN_MILLIS, "89 minutes ago");
    }

    @Test
    public void testFormatHours() {
        assertFormat(90, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(149, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(35, HOUR_IN_MILLIS, "35 hours ago");
    }

    @Test
    public void testFormatDays() {
        assertFormat(36, HOUR_IN_MILLIS, "2 days ago");
        assertFormat(13, DAY_IN_MILLIS, "13 days ago");
    }

    @Test
    public void testFormatWeeks() {
        assertFormat(14, DAY_IN_MILLIS, "2 weeks ago");
        assertFormat(69, DAY_IN_MILLIS, "10 weeks ago");
    }

    @Test
    public void testFormatMonths() {
        assertFormat(70, DAY_IN_MILLIS, "2 months ago");
        assertFormat(75, DAY_IN_MILLIS, "3 months ago");
        assertFormat(364, DAY_IN_MILLIS, "12 months ago");
    }

    @Test
    public void testFormatYearsMonths() {

        assertFormat(410, DAY_IN_MILLIS, "1 year, 2 months ago");
        assertFormat(2, YEAR_IN_MILLIS, "2 years ago");
        assertFormat(1824, DAY_IN_MILLIS, "4 years, 12 months ago");
    }

    @Test
    public void testFormatYears() {
        assertFormat(5, YEAR_IN_MILLIS, "5 years ago");
        assertFormat(60, YEAR_IN_MILLIS, "60 years ago");
    }
}


assertFormat(410, DAY_IN_MILLIS, "1 year, 2 months ago");
        assertFormat(2, YEAR_IN_MILLIS, "2 years ago");

/*
 * and other copyright owners as documented in the project's IP log.
 *
 *
 * All rights reserved.
 *
 */
package org.eclipse.jgit.util;

import static org.eclipse.jgit.util.RelativeDateFormatter.DAY_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.HOUR_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.MINUTE_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.SECOND_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.YEAR_IN_MILLIS;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.eclipse.jgit.junit.MockSystemReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RelativeDateFormatterTest {

    @Before
    public void setUp() {
        SystemReader.setInstance(new MockSystemReader());
    }

    @After
    public void tearDown() {
        SystemReader.setInstance(null);
    }

    private static void assertFormat(long ageFromNow, long timeUnit, String expectedFormat) {
        Date d = new Date(SystemReader.getInstance().getCurrentTime() - ageFromNow * timeUnit);
        String s = RelativeDateFormatter.format(d);
        assertEquals(expectedFormat, s);
    }

    @Test
    public void testFuture() {
        assertFormat(-100, YEAR_IN_MILLIS, "in the future");
        assertFormat(-1, SECOND_IN_MILLIS, "in the future");
    }

    @Test
    public void testFormatSeconds() {
        assertFormat(1, SECOND_IN_MILLIS, "1 seconds ago");
        assertFormat(89, SECOND_IN_MILLIS, "89 seconds ago");
    }

    @Test
    public void testFormatMinutes() {
        assertFormat(90, SECOND_IN_MILLIS, "2 minutes ago");
        assertFormat(3, MINUTE_IN_MILLIS, "3 minutes ago");
        assertFormat(60, MINUTE_IN_MILLIS, "60 minutes ago");
        assertFormat(89, MINUTE_IN_MILLIS, "89 minutes ago");
    }

    @Test
    public void testFormatHours() {
        assertFormat(90, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(149, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(35, HOUR_IN_MILLIS, "35 hours ago");
    }

    @Test
    public void testFormatDays() {
        assertFormat(36, HOUR_IN_MILLIS, "2 days ago");
        assertFormat(13, DAY_IN_MILLIS, "13 days ago");
    }

    @Test
    public void testFormatWeeks() {
        assertFormat(14, DAY_IN_MILLIS, "2 weeks ago");
        assertFormat(69, DAY_IN_MILLIS, "10 weeks ago");
    }

    @Test
    public void testFormatMonths() {
        assertFormat(70, DAY_IN_MILLIS, "2 months ago");
        assertFormat(75, DAY_IN_MILLIS, "3 months ago");
        assertFormat(364, DAY_IN_MILLIS, "12 months ago");
    }

    @Test
    public void testFormatYearsMonths() {
        assertFormat(366, DAY_IN_MILLIS, "1 year ago");
        assertFormat(380, DAY_IN_MILLIS, "1 year, 1 month ago");

        assertFormat(1824, DAY_IN_MILLIS, "4 years, 12 months ago");
    }

    @Test
    public void testFormatYears() {
        assertFormat(5, YEAR_IN_MILLIS, "5 years ago");
        assertFormat(60, YEAR_IN_MILLIS, "60 years ago");
    }
}


assertFormat(1824, DAY_IN_MILLIS, "4 years, 12 months ago");
    }

/*
 * and other copyright owners as documented in the project's IP log.
 *
 *
 * All rights reserved.
 *
 */
package org.eclipse.jgit.util;

import static org.eclipse.jgit.util.RelativeDateFormatter.DAY_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.HOUR_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.MINUTE_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.SECOND_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.YEAR_IN_MILLIS;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.eclipse.jgit.junit.MockSystemReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RelativeDateFormatterTest {

    @Before
    public void setUp() {
        SystemReader.setInstance(new MockSystemReader());
    }

    @After
    public void tearDown() {
        SystemReader.setInstance(null);
    }

    private static void assertFormat(long ageFromNow, long timeUnit, String expectedFormat) {
        Date d = new Date(SystemReader.getInstance().getCurrentTime() - ageFromNow * timeUnit);
        String s = RelativeDateFormatter.format(d);
        assertEquals(expectedFormat, s);
    }

    @Test
    public void testFuture() {
        assertFormat(-100, YEAR_IN_MILLIS, "in the future");
        assertFormat(-1, SECOND_IN_MILLIS, "in the future");
    }

    @Test
    public void testFormatSeconds() {
        assertFormat(1, SECOND_IN_MILLIS, "1 seconds ago");
        assertFormat(89, SECOND_IN_MILLIS, "89 seconds ago");
    }

    @Test
    public void testFormatMinutes() {
        assertFormat(90, SECOND_IN_MILLIS, "2 minutes ago");
        assertFormat(3, MINUTE_IN_MILLIS, "3 minutes ago");
        assertFormat(60, MINUTE_IN_MILLIS, "60 minutes ago");
        assertFormat(89, MINUTE_IN_MILLIS, "89 minutes ago");
    }

    @Test
    public void testFormatHours() {
        assertFormat(90, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(149, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(35, HOUR_IN_MILLIS, "35 hours ago");
    }

    @Test
    public void testFormatDays() {
        assertFormat(36, HOUR_IN_MILLIS, "2 days ago");
        assertFormat(13, DAY_IN_MILLIS, "13 days ago");
    }

    @Test
    public void testFormatWeeks() {
        assertFormat(14, DAY_IN_MILLIS, "2 weeks ago");
        assertFormat(69, DAY_IN_MILLIS, "10 weeks ago");
    }

    @Test
    public void testFormatMonths() {
        assertFormat(70, DAY_IN_MILLIS, "2 months ago");
        assertFormat(75, DAY_IN_MILLIS, "3 months ago");
        assertFormat(364, DAY_IN_MILLIS, "12 months ago");
    }

    @Test
    public void testFormatYearsMonths() {
        assertFormat(366, DAY_IN_MILLIS, "1 year ago");
        assertFormat(380, DAY_IN_MILLIS, "1 year, 1 month ago");
        assertFormat(410, DAY_IN_MILLIS, "1 year, 2 months ago");
        assertFormat(2, YEAR_IN_MILLIS, "2 years ago");

    @Test
    public void testFormatYears() {
        assertFormat(5, YEAR_IN_MILLIS, "5 years ago");
        assertFormat(60, YEAR_IN_MILLIS, "60 years ago");
    }
}


mat(60, MINUTE_IN_MILLIS, "60 minutes ago");

/*
 * and other copyright owners as documented in the project's IP log.
 *
 *
 * All rights reserved.
 *
 */
package org.eclipse.jgit.util;

import static org.eclipse.jgit.util.RelativeDateFormatter.DAY_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.HOUR_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.MINUTE_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.SECOND_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.YEAR_IN_MILLIS;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.eclipse.jgit.junit.MockSystemReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RelativeDateFormatterTest {

    @Before
    public void setUp() {
        SystemReader.setInstance(new MockSystemReader());
    }

    @After
    public void tearDown() {
        SystemReader.setInstance(null);
    }

    private static void assertFormat(long ageFromNow, long timeUnit, String expectedFormat) {
        Date d = new Date(SystemReader.getInstance().getCurrentTime() - ageFromNow * timeUnit);
        String s = RelativeDateFormatter.format(d);
        assertEquals(expectedFormat, s);
    }

    @Test
    public void testFuture() {
        assertFormat(-100, YEAR_IN_MILLIS, "in the future");
        assertFormat(-1, SECOND_IN_MILLIS, "in the future");
    }

    @Test
    public void testFormatSeconds() {
        assertFormat(1, SECOND_IN_MILLIS, "1 seconds ago");
        assertFormat(89, SECOND_IN_MILLIS, "89 seconds ago");
    }

    @Test
    public void testFormatMinutes() {
        assertFormat(90, SECOND_IN_MILLIS, "2 minutes ago");
        assertFormat(3, MINUTE_IN_MILLIS, "3 minutes ago");
        assertFor

        assertFormat(89, MINUTE_IN_MILLIS, "89 minutes ago");
    }

    @Test
    public void testFormatHours() {
        assertFormat(90, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(149, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(35, HOUR_IN_MILLIS, "35 hours ago");
    }

    @Test
    public void testFormatDays() {
        assertFormat(36, HOUR_IN_MILLIS, "2 days ago");
        assertFormat(13, DAY_IN_MILLIS, "13 days ago");
    }

    @Test
    public void testFormatWeeks() {
        assertFormat(14, DAY_IN_MILLIS, "2 weeks ago");
        assertFormat(69, DAY_IN_MILLIS, "10 weeks ago");
    }

    @Test
    public void testFormatMonths() {
        assertFormat(70, DAY_IN_MILLIS, "2 months ago");
        assertFormat(75, DAY_IN_MILLIS, "3 months ago");
        assertFormat(364, DAY_IN_MILLIS, "12 months ago");
    }

    @Test
    public void testFormatYearsMonths() {
        assertFormat(366, DAY_IN_MILLIS, "1 year ago");
        assertFormat(380, DAY_IN_MILLIS, "1 year, 1 month ago");
        assertFormat(410, DAY_IN_MILLIS, "1 year, 2 months ago");
        assertFormat(2, YEAR_IN_MILLIS, "2 years ago");
        assertFormat(1824, DAY_IN_MILLIS, "4 years, 12 months ago");
    }

    @Test
    public void testFormatYears() {
        assertFormat(5, YEAR_IN_MILLIS, "5 years ago");
        assertFormat(60, YEAR_IN_MILLIS, "60 years ago");
    }
}


/*
 * and other copyright owners as documented in the project's IP log.
 *
 *
 * All rights reserved.
 *
 */
package org.eclipse.jgit.util;

import static org.eclipse.jgit.util.RelativeDateFormatter.DAY_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.HOUR_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.MINUTE_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.SECOND_IN_MILLIS;
import static org.eclipse.jgit.util.RelativeDateFormatter.YEAR_IN_MILLIS;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.eclipse.jgit.junit.MockSystemReader;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class RelativeDateFormatterTest {

    @Before
    public void setUp() {
        SystemReader.setInstance(new MockSystemReader());
    }

    @After
    public void tearDown() {
        SystemReader.setInstance(null);
    }

    private static void assertFormat(long ageFromNow, long timeUnit, String expectedFormat) {
        Date d = new Date(SystemReader.getInstance().getCurrentTime() - ageFromNow * timeUnit);
        String s = RelativeDateFormatter.format(d);
        assertEquals(expectedFormat, s);
    }

    @Test
    public void testFutu

re() {
        assertFormat(-100, YEAR_IN_MILLIS, "in the future");
        assertFormat(-1, SECOND_IN_MILLIS, "in the future");
    }

    @Test
    public void testFormatSeconds() {
        assertFormat(1, SECOND_IN_MILLIS, "1 seconds ago");
        assertFormat(89, SECOND_IN_MILLIS, "89 seconds ago");
    }

    @Test
    public void testFormatMinutes() {
        assertFormat(90, SECOND_IN_MILLIS, "2 minutes ago");
        assertFormat(3, MINUTE_IN_MILLIS, "3 minutes ago");
        assertFormat(60, MINUTE_IN_MILLIS, "60 minutes ago");
        assertFormat(89, MINUTE_IN_MILLIS, "89 minutes ago");
    }

    @Test
    public void testFormatHours() {
        assertFormat(90, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(149, MINUTE_IN_MILLIS, "2 hours ago");
        assertFormat(35, HOUR_IN_MILLIS, "35 hours ago");
    }

    @Test
    public void testFormatDays() {
        assertFormat(36, HOUR_IN_MILLIS, "2 days ago");
        assertFormat(13, DAY_IN_MILLIS, "13 days ago");
    }

    @Test
    public void testFormatWeeks() {
        assertFormat(14, DAY_IN_MILLIS, "2 weeks ago");
        assertFormat(69, DAY_IN_MILLIS, "10 weeks ago");
    }

    @Test
    public void testFormatMonths() {
        assertFormat(70, DAY_IN_MILLIS, "2 months ago");
        assertFormat(75, DAY_IN_MILLIS, "3 months ago");
        assertFormat(364, DAY_IN_MILLIS, "12 months ago");
    }

    @Test
    public void testFormatYearsMonths() {
        assertFormat(366, DAY_IN_MILLIS, "1 year ago");
        assertFormat(380, DAY_IN_MILLIS, "1 year, 1 month ago");
        assertFormat(410, DAY_IN_MILLIS, "1 year, 2 months ago");
        assertFormat(2, YEAR_IN_MILLIS, "2 years ago");
        assertFormat(1824, DAY_IN_MILLIS, "4 years, 12 months ago");
    }

    @Test
    public void testFormatYears() {
        assertFormat(5, YEAR_IN_MILLIS, "5 years ago");
        assertFormat(60, YEAR_IN_MILLIS, "60 years ago");
    }
}


// 07/17/2009 - tware - added tests for DDL generation of maps
package org.eclipse.persistence.testing.models.jpa.ddlgeneration;

import java.math.BigDecimal;

pu

blic class Money {

    private BigDecimal amount;

    private Currency currency;

    public Money() {
    }

    public Money(BigDecimal amount, Currency currency) {
        super();
        this.amount = amount;
        this.currency = currency;
    }
}


/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times
        for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);
                    if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(v1)][index(v2)]);
                }
            }
        }
    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */
    public double shortestDistance(V v1, V v2) {
        return d[index(v1)][index(v2)];
    }

{
        return diameter;
    }

    private int index(V vertex) {
        Integer index = indices.get(vertex);
        if (index == null) {
            indices.put(vertex, nextIndex);
            index = nextIndex++;
        }
        return index;
    }
}
// End FloydWarshallShortestPaths.java


{
        return d[index(v1)][index(v2)];
    }

/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times
        for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);
                    if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(v1)][index(v2)]);
                }
            }
        }
    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */
    public double shortestDistance(V v1, V v2)

    public double getDiameter() {
        return diameter;
    }

    private int index(V vertex) {
        Integer index = indices.get(vertex);
        if (index == null) {
            indices.put(vertex, nextIndex);
            index = nextIndex++;
        }
        return index;
    }
}
// End FloydWarshallShortestPaths.java


/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times
        for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);
                    if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(v1)][index(v2)]);
                }
            }
        }
    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */
    public double shortestDistance(V v1, V v2) {
        return d[index(v1)][index(v2)];
    }

    public double getDiameter() {
        return diameter;
    }

    private int index(V vertex) {

        if (index == null) {
            indices.put(vertex, nextIndex);
            index = nextIndex++;
        }
        return index;
    }
}
// End FloydWarshallShortestPaths.java


if (index == null) {
            indices.put(vertex, nextIndex);
            index = nextIndex++;
        }

/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times
        for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);
                    if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(v1)][index(v2)]);
                }
            }
        }
    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */
    public double shortestDistance(V v1, V v2) {
        return d[index(v1)][index(v2)];
    }

    public double getDiameter() {
        return diameter;
    }

    private int index(V vertex) {
        Integer index = indices.get(vertex);

        return index;
    }
}
// End FloydWarshallShortestPaths.java


/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times
        for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);
                    if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(v1)][index(v2)]);
                }
            }
        }
    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */
    public double shortestDistance(V v1, V v2) {
        return d[index(v1)][index(v2)];
    }

    public double getDiameter() {
        return diameter;
    }

    private int index(V vertex) {
        Integer index = indices.get(vertex);
        if (index == null) {
            indices.put(vertex, nextIndex);
            index = nextIndex++;
        }

}
// End FloydWarshallShortestPaths.java


/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times
        for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);
                    if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(v1)][index(v2)]);
                }
            }
        }
    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */
    public double shortestDistance(V v1, V v2) {
        return d[index(v1)][index(v2)];
    }

    public double getDiameter() {
        return diameter;
    }

    private int index(V vertex) {
        Integer


public double shortestDistance(V v1, V v2) {
        return d[index(v1)][index(v2)];
    }

/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times
        for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);
                    if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(v1)][index(v2)]);
                }
            }
        }
    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */


if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(v1)][index(v2)]);

/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times
        for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);

                }
            }
        }
    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */
    public double shortestDistance(V v1, V v2) {
        return d[index(v1)][index(v2)];
    }

    public double getDiameter() {
        return diameter;
    }

    private int index(V vertex) {
        Integer index = indices.get(vertex);
        if (index == null) {
            indices.put(vertex, nextIndex);
            index = nextIndex++;
        }
        return index;
    }
}
// End FloydWarshallShortestPaths.java


for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);
                    if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(v1)][index(v2)]);
                }
            }
        }

/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times

    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */
    public double shortestDistance(V v1, V v2) {
        return d[index(v1)][index(v2)];
    }

    public double getDiameter() {
        return diameter;
    }

    private int index(V vertex) {
        Integer index = indices.get(vertex);
        if (index == null) {
            indices.put(vertex, nextIndex);
            index = nextIndex++;
        }
        return index;
    }
}
// End FloydWarshallShortestPaths.java


/**
 * This file is part of EvoSuite.
 */
/*
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation,
 * Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */
import java.util.*;
import org.jgrapht.*;

/**
 * The
 * Floyd-Warshall algorithm finds all shortest paths (all n^2 of them) in
 * O(n^3) time. This also works out the graph diameter during the process.
 *
 * @author Tom Larkworthy
 */
public class FloydWarshall<V, E> {

    int nextIndex = 0;

    HashMap<V, Integer> indices;

    double[][] d;

    double diameter;

    /**
     * Constructs the shortest path array for the given graph.
     *
     * @param g input graph
     * @param <V> a V object.
     * @param <E> a E object.
     */
    public FloydWarshall(Graph<V, E> g) {
        int sz = g.vertexSet().size();
        d = new double[sz][sz];
        indices = new HashMap<V, Integer>();
        // Initialise distance to infinity, or the neighbours weight, or 0 if
        // same
        for (V v1 : g.vertexSet()) {
            for (V v2 : g.vertexSet()) {
                if (v1 == v2) {
                    d[index(v1)][index(v2)] = 0;
                } else {
                    E e = g.getEdge(v1, v2);
                    if (e == null) {
                        d[index(v1)][index(v2)] = Double.POSITIVE_INFINITY;
                    } else {
                        d[index(v1)][index(v2)] = g.getEdgeWeight(e);
                    }
                }
            }
        }
        // now iterate k times
        for (int k = 0; k < sz; k++) {
            for (V v1 : g.vertexSet()) {
                for (V v2 : g.vertexSet()) {
                    d[index(v1)][index(v2)] = Math.min(d[index(v1)][index(v2)], d[index(v1)][k] + d[k][index(v2)]);
                    if (Double.POSITIVE_INFINITY != d[index(v1)][index(v2)])
                        diameter = Math.max(diameter, d[index(

v1)][index(v2)]);
                }
            }
        }
    }

    /**
     * Retrieves the shortest distance between two vertices.
     *
     * @param v1 first vertex
     * @param v2 second vertex
     * @return distance, or positive infinity if no path
     */
    public double shortestDistance(V v1, V v2) {
        return d[index(v1)][index(v2)];
    }

    public double getDiameter() {
        return diameter;
    }

    private int index(V vertex) {
        Integer index = indices.get(vertex);
        if (index == null) {
            indices.put(vertex, nextIndex);
            index = nextIndex++;
        }
        return index;
    }
}
// End FloydWarshallShortestPaths.java


package org.apache.rocketmq.client.consumer.listener;

public enum ConsumeConcurrentlyStatus {

    /**
     *

Success consumption
     */
    CONSUME_SUCCESS,
    /**
     * Failure consumption,later try to consume
     */
    RECONSUME_LATER
}


public static TileTransition getInstanceMappedToKey(int keycode) throws NoSuchElementException

package freerails.client;

import freerails.model.terrain.TileTransition;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * Maps keys to OneTileMoveVectors.
 */
public class KeyCodeToOneTileMoveVector {

    private static final Map<Integer, TileTransition> keycode2vector = new HashMap<>();

    static {
        // Set up key mappings...
        // Num pad with num lock on
        keycode2vector.put(KeyEvent.VK_NUMPAD1, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD2, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD3, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD4, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD6, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD7, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD8, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD9, TileTransition.NORTH_EAST);
        // Num pad with num lock off
        keycode2vector.put(KeyEvent.VK_END, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_DOWN, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_PAGE_DOWN, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_LEFT, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_RIGHT, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_HOME, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_UP, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_PAGE_UP, TileTransition.NORTH_EAST);
    }

    private KeyCodeToOneTileMoveVector() {
    }

    /**
     * Returns the OneTileMoveVector that is mapped to the specified keycode.
     */

{
        Integer integer = keycode;
        if (!keycode2vector.containsKey(integer)) {
            throw new NoSuchElementException(String.valueOf(keycode));
        }
        return keycode2vector.get(integer);
    }
}


{
        Integer integer = keycode;
        if (!keycode2vector.containsKey(integer)) {
            throw new NoSuchElementException(String.valueOf(keycode));
        }
        return keycode2vector.get(integer);
    }

package freerails.client;

import freerails.model.terrain.TileTransition;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * Maps keys to OneTileMoveVectors.
 */
public class KeyCodeToOneTileMoveVector {

    private static final Map<Integer, TileTransition> keycode2vector = new HashMap<>();

    static {
        // Set up key mappings...
        // Num pad with num lock on
        keycode2vector.put(KeyEvent.VK_NUMPAD1, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD2, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD3, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD4, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD6, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD7, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD8, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD9, TileTransition.NORTH_EAST);
        // Num pad with num lock off
        keycode2vector.put(KeyEvent.VK_END, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_DOWN, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_PAGE_DOWN, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_LEFT, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_RIGHT, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_HOME, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_UP, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_PAGE_UP, TileTransition.NORTH_EAST);
    }

    private KeyCodeToOneTileMoveVector() {
    }

    /**
     * Returns the OneTileMoveVector that is mapped to the specified keycode.
     */
    public static TileTransition getInstanceMappedToKey(int keycode) throws NoSuchElementException


package freerails.client;

import freerails.model.terrain.TileTransition;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * Maps keys to OneTileMoveVectors.
 */
public class KeyCodeToOneTileMoveVector {

    private static final Map<Integer, TileTransition> keycode2vector = new HashMap<>();

    static {
        // Set up key mappings...
        // Num pad with num lock on
        keycode2vector.put(KeyEvent.VK_NUMPAD1, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD2, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD3, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD4, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD6, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD7, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD8, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD9, TileTransition.NORTH_EAST);
        // Num pad with num lock off
        keycode2vector.put(KeyEvent.VK_END, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_DOWN, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_PAGE_DOWN, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_LEFT, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_RIGHT, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_HOME, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_UP, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_PAGE_UP, TileTransition.NORTH_EAST);
    }

    private KeyCodeToOneTileMoveVector() {
    }

    /**
     * Returns the OneTileMoveVector that is mapped to the specified keycode.
     */
    public static TileTransition getInstanceMappedToKey(int keycode) throws NoSuchElementException {

        if (!keycode2vector.containsKey(integer)) {
            throw new NoSuchElementException(String.valueOf(keycode));
        }
        return keycode2vector.get(integer);
    }
}


if (!keycode2vector.containsKey(integer)) {
            throw new NoSuchElementException(String.valueOf(keycode));
        }

package freerails.client;

import freerails.model.terrain.TileTransition;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * Maps keys to OneTileMoveVectors.
 */
public class KeyCodeToOneTileMoveVector {

    private static final Map<Integer, TileTransition> keycode2vector = new HashMap<>();

    static {
        // Set up key mappings...
        // Num pad with num lock on
        keycode2vector.put(KeyEvent.VK_NUMPAD1, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD2, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD3, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD4, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD6, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD7, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD8, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD9, TileTransition.NORTH_EAST);
        // Num pad with num lock off
        keycode2vector.put(KeyEvent.VK_END, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_DOWN, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_PAGE_DOWN, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_LEFT, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_RIGHT, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_HOME, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_UP, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_PAGE_UP, TileTransition.NORTH_EAST);
    }

    private KeyCodeToOneTileMoveVector() {
    }

    /**
     * Returns the OneTileMoveVector that is mapped to the specified keycode.
     */
    public static TileTransition getInstanceMappedToKey(int keycode) throws NoSuchElementException {
        Integer integer = keycode;

        return keycode2vector.get(integer);
    }
}


return keycode2vector.get(integer);
    }

package freerails.client;

import freerails.model.terrain.TileTransition;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * Maps keys to OneTileMoveVectors.
 */
public class KeyCodeToOneTileMoveVector {

    private static final Map<Integer, TileTransition> keycode2vector = new HashMap<>();

    static {
        // Set up key mappings...
        // Num pad with num lock on
        keycode2vector.put(KeyEvent.VK_NUMPAD1, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD2, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD3, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD4, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD6, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD7, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD8, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD9, TileTransition.NORTH_EAST);
        // Num pad with num lock off
        keycode2vector.put(KeyEvent.VK_END, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_DOWN, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_PAGE_DOWN, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_LEFT, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_RIGHT, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_HOME, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_UP, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_PAGE_UP, TileTransition.NORTH_EAST);
    }

    private KeyCodeToOneTileMoveVector() {
    }

    /**
     * Returns the OneTileMoveVector that is mapped to the specified keycode.
     */
    public static TileTransition getInstanceMappedToKey(int keycode) throws NoSuchElementException {
        Integer integer = keycode;
        if (!keycode2vector.containsKey(integer)) {
            throw new NoSuchElementException(String.valueOf(keycode));
        }


package freerails.client;

import freerails.model.terrain.TileTransition;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * Maps keys to OneTileMoveVectors.
 */
public class KeyCodeToOneTileMoveVector {

    private static final Map<Integer, TileTransition> keycode2vector = new HashMap<>();

    static {
        // Set up key mappings...
        // Num pad with num lock on
        keycode2vector.put(KeyEvent.VK_NUMPAD1, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD2, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD3, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD4, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD6, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD7, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD8, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD9, TileTransition.NORTH_EAST);
        // Num pad with num lock off
        keycode2vector.put(KeyEvent.VK_END, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_DOWN, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_PAGE_DOWN, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_LEFT, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_RIGHT, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_HOME, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_UP, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_PAGE_UP, TileTransition.NORTH_EAST);
    }

    private KeyCodeToOneTileMoveVector() {
    }

    /**
     * Returns the OneTileMoveVector that is mapped to the specified keycode.
     */
    public static TileTransition getInstanceMappedToKey(int keycode) throws NoSuchElementException {
        Integer integer = keycode;
        if (!keycode2vector.containsKey(integer)) {
            throw new NoSuchElementException(String.valueOf(keycode));
        }
        return keycode2vect


public static TileTransition getInstanceMappedToKey(int keycode) throws NoSuchElementException {
        Integer integer = keycode;
        if (!keycode2vector.containsKey(integer)) {
            throw new NoSuchElementException(String.valueOf(keycode));
        }
        return keycode2vector.get(integer);
    }


package freerails.client;

import freerails.model.terrain.TileTransition;
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;

/**
 * Maps keys to OneTileMoveVectors.
 */
public class KeyCodeToOneTileMoveVector {

    private static final Map<Integer, TileTransition> keycode2vector =

new HashMap<>();

    static {
        // Set up key mappings...
        // Num pad with num lock on
        keycode2vector.put(KeyEvent.VK_NUMPAD1, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD2, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD3, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD4, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD6, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_NUMPAD7, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_NUMPAD8, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_NUMPAD9, TileTransition.NORTH_EAST);
        // Num pad with num lock off
        keycode2vector.put(KeyEvent.VK_END, TileTransition.SOUTH_WEST);
        keycode2vector.put(KeyEvent.VK_DOWN, TileTransition.SOUTH);
        keycode2vector.put(KeyEvent.VK_PAGE_DOWN, TileTransition.SOUTH_EAST);
        keycode2vector.put(KeyEvent.VK_LEFT, TileTransition.WEST);
        keycode2vector.put(KeyEvent.VK_RIGHT, TileTransition.EAST);
        keycode2vector.put(KeyEvent.VK_HOME, TileTransition.NORTH_WEST);
        keycode2vector.put(KeyEvent.VK_UP, TileTransition.NORTH);
        keycode2vector.put(KeyEvent.VK_PAGE_UP, TileTransition.NORTH_EAST);
    }

    private KeyCodeToOneTileMoveVector() {
    }

    /**
     * Returns the OneTileMoveVector that is mapped to the specified keycode.
     */
    public static TileTransition getInstanceMappedToKey(int keycode) throws NoSuchElementException {
        Integer integer = keycode;
        if (!keycode2vector.containsKey(integer)) {
            throw new NoSuchElementException(String.valueOf(keycode));
        }
        return keycode2vector.get(integer);
    }
}


@Override
    public Resources getResources(final String locale)

package io.github.lonamiwebs.stringlate.classes.sources;

import net.gsantner.opoc.util.FileUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.github.lonamiwebs.stringlate.classes.Messenger;
import io.github.lonamiwebs.stringlate.classes.git.GitCloneProgressCallback;
import io.github.lonamiwebs.stringlate.classes.git.GitWrapper;
import io.github.lonamiwebs.stringlate.classes.resources.Resources;
import io.github.lonamiwebs.stringlate.classes.resources.tags.ResTag;
import io.github.lonamiwebs.stringlate.interfaces.StringsSource;

public class GitSource implements StringsSource {

    private File mWorkDir;

    private final String mGitUrl, mBranch;

    private final HashMap<String, ArrayList<File>> mLocaleFiles;

    private GitCloneProgressCallback mCloneCallback;

    private boolean mCancelled;

    private File iconFile;

    // Match locale from "values-(…)/strings.xml"
    private final static Pattern VALUES_LOCALE_PATTERN = Pattern.compile("values(?:-([\\w-]+))?/.+?\\.xml");

    private static final Pattern DO_NOT_TRANSLATE = Pattern.compile("(?:do?[ _-]*no?t?|[u|i]n)[ _-]*trans(?:lat(?:e|able))?");

    public GitSource(final String gitUrl, final String branch) {
        mGitUrl = gitUrl;
        mBranch = branch;
        mLocaleFiles = new HashMap<>();
    }

    @Override
    public boolean setup(final SourceSettings settings, final File workDir, final int desiredIconDpi, final Messenger.OnSyncProgress callback) {
        callback.onUpdate(1, 0f);
        settings.set("git_url", mGitUrl);
        mWorkDir = workDir;
        // 2. Clone the repository itself
        mCloneCallback = new GitCloneProgressCallback(callback);
        if (!GitWrapper.cloneRepo(mGitUrl, mWorkDir, mBranch, mCloneCallback) || mCancelled) {
            // TODO These messages are still useful, show them somehow?
            return false;
        }
        // Cache all the repository resources here for faster look-up on upcoming methods
        final GitWrapper.RepositoryResources repoResources = GitWrapper.findUsefulResources(mWorkDir);
        final ArrayList<File> resourceFiles = GitWrapper.searchAndroidResources(repoResources);
        if (resourceFiles.isEmpty() || mCancelled) {
            return false;
        }
        // Save the branches of this repository
        settings.setArray("remote_branches", GitWrapper.getBranches(mWorkDir));
        iconFile = GitWrapper.findProperIcon(repoResources, desiredIconDpi);
        // Iterate over all the found resources to sort them by locale
        for (File resourceFile : resourceFiles) {
            Matcher m = VALUES_LOCALE_PATTERN.matcher(resourceFile.getAbsolutePath());
            // Ensure that we can tell the locale from the path (otherwise it's invalid)
            if (m.find()) {
                if (m.group(1) == null) {
                    // Default locale
                    // If the file name is something like "do not translate", skip it
                    if (DO_NOT_TRANSLATE.matcher(resourceFile.getName()).find())
                        continue;
                }
                // TODO Can I use .getOrDefault()? It shows an error so let's not risk
                if (!mLocaleFiles.containsKey(m.group(1)))
                    mLocaleFiles.put(m.group(1), new ArrayList<File>());
                mLocaleFiles.get(m.group(1)).add(resourceFile);
            }
        }
        settings.set("translation_service", GitWrapper.mayUseTranslationServices(repoResources));
        return !mCancelled;
    }

    @Override
    public void cancel() {
        if (mCloneCallback != null) {
            mCloneCallback.cancel();
        }
        mCancelled = true;
    }

    @Override
    public String getName() {
        return "git";
    }

    @Override
    public List<String> getLocales() {
        final ArrayList<String> result = new ArrayList<>(mLocaleFiles.size());
        for (String locale : mLocaleFiles.keySet()) if (locale != null)
            result.add(locale);
        return result;
    }

{
        final Resources result = Resources.empty();
        for (File file : mLocaleFiles.get(locale)) {
            for (ResTag rt : Resources.fromFile(file)) result.addTag(rt);
        }
        return result;
    }

    @Override
    public List<String> getDefaultResources() {
        final ArrayList<String> result = new ArrayList<>(mLocaleFiles.get(null).size());
        for (File file : mLocaleFiles.get(null)) result.add(getDefaultResourceName(file));
        return result;
    }

    @Override
    public Resources getDefaultResource(String name) {
        for (File file : mLocaleFiles.get(null)) if (getDefaultResourceName(file).equals(name))
            return Resources.fromFile(file);
        throw new IllegalArgumentException("No default resources were found with that name");
    }

    @Override
    public String getDefaultResourceXml(String name) {
        for (File file : mLocaleFiles.get(null)) if (getDefaultResourceName(file).equals(name))
            return FileUtils.readTextFile(file);
        throw new IllegalArgumentException("No XML was found with that name");
    }

    @Override
    public File getIcon() {
        return iconFile;
    }

    private String getDefaultResourceName(final File file) {
        return file.getAbsolutePath().substring(mWorkDir.getAbsolutePath().length() + 1);
    }

    @Override
    public void dispose() {
        FileUtils.deleteRecursive(mWorkDir);
        mLocaleFiles.clear();
        iconFile = null;
    }
}


package io.github.lonamiwebs.stringlate.classes.sources;

import net.gsantner.opoc.util.FileUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.github.lonamiwebs.stringlate.classes.Messenger;
import io.github.lonamiwebs.stringlate.classes.git.GitCloneProgressCallback;
import io.github.lonamiwebs.stringlate.classes.git.GitWrapper;
import io.github.lonamiwebs.stringlate.classes.resources.Resources;
import io.github.lonamiwebs.stringlate.classes.resources.tags.ResTag;
import io.github.lonamiwebs.stringlate.interfaces.StringsSource;

public class GitSource implements StringsSource {

    private File mWorkDir;

    private final String mGitUrl, mBranch;

    private final HashMap<String, ArrayList<File>> mLocaleFiles;

    private GitCloneProgressCallback mCloneCallback;

    private boolean mCancelled;

    private File iconFile;

    // Match locale from "values-(…)/strings.xml"
    private final static Pattern VALUES_LOCALE_PATTERN = Pattern.compile("values(?:-([\\w-]+))?/.+?\\.xml");

    private static final Pattern DO_NOT_TRANSLATE = Pattern.compile("(?:do?[ _-]*no?t?|[u|i]n)[ _-]*trans(?:lat(?:e|able))?");

    public GitSource(final String gitUrl, final String branch) {
        mGitUrl = gitUrl;
        mBranch = branch;
        mLocaleFiles = new HashMap<>();
    }

    @Override
    public boolean setup(final SourceSettings settings, final File workDir, final int desiredIconDpi, final Messenger.OnSyncProgress callback) {
        callback.onUpdate(1, 0f);
        settings.set("git_url", mGitUrl);
        mWorkDir = workDir;
        // 2. Clone the repository itself
        mCloneCallback = new GitCloneProgressCallback(callback);
        if (!GitWrapper.cloneRepo(mGitUrl, mWorkDir, mBranch, mCloneCallback) || mCancelled) {
            // TODO These messages are still useful, show them somehow?
            return false;
        }
        // Cache all the repository resources here for faster look-up on upcoming methods
        final GitWrapper.RepositoryResources repoResources = GitWrapper.findUsefulResources(mWorkDir);
        final ArrayList<File> resourceFiles = GitWrapper.searchAndroidResources(repoResources);
        if (resourceFiles.isEmpty() || mCancelled) {
            return false;
        }
        // Save the branches of this repository
        settings.setArray("remote_branches", GitWrapper.getBranches(mWorkDir));
        iconFile = GitWrapper.findProperIcon(repoResources, desiredIconDpi);
        // Iterate over all the found resources to sort them by locale
        for (File resourceFile : resourceFiles) {
            Matcher m = VALUES_LOCALE_PATTERN.matcher(resourceFile.getAbsolutePath());
            // Ensure that we can tell the locale from the path (otherwise it's invalid)
            if (m.find()) {
                if (m.group(1) == null) {
                    // Default locale
                    // If the file name is something like "do not translate", skip it
                    if (DO_NOT_TRANSLATE.matcher(resourceFile.getName()).find())
                        continue;
                }
                // TODO Can I use .getOrDefault()? It shows an error so let's not risk
                if (!mLocaleFiles.containsKey(m.group(1)))
                    mLocaleFiles.put(m.group(1), new ArrayList<File>());
                mLocaleFiles.get(m.group(1)).add(resourceFile);
            }
        }
        settings.set("translation_service", GitWrapper.mayUseTranslationServices(repoResources));
        return !mCancelled;
    }

    @Override
    public void cancel() {
        if (mCloneCallback != null) {
            mCloneCallback.cancel();
        }
        mCancelled = true;
    }

    @Override
    public String getName()

    @Override
    public List<String> getLocales() {
        final ArrayList<String> result = new ArrayList<>(mLocaleFiles.size());
        for (String locale : mLocaleFiles.keySet()) if (locale != null)
            result.add(locale);
        return result;
    }

    @Override
    public Resources getResources(final String locale) {
        final Resources result = Resources.empty();
        for (File file : mLocaleFiles.get(locale)) {
            for (ResTag rt : Resources.fromFile(file)) result.addTag(rt);
        }
        return result;
    }

    @Override
    public List<String> getDefaultResources() {
        final ArrayList<String> result = new ArrayList<>(mLocaleFiles.get(null).size());
        for (File file : mLocaleFiles.get(null)) result.add(getDefaultResourceName(file));
        return result;
    }

    @Override
    public Resources getDefaultResource(String name) {
        for (File file : mLocaleFiles.get(null)) if (getDefaultResourceName(file).equals(name))
            return Resources.fromFile(file);
        throw new IllegalArgumentException("No default resources were found with that name");
    }

    @Override
    public String getDefaultResourceXml(String name) {
        for (File file : mLocaleFiles.get(null)) if (getDefaultResourceName(file).equals(name))
            return FileUtils.readTextFile(file);
        throw new IllegalArgumentException("No XML was found with that name");
    }

    @Override
    public File getIcon() {
        return iconFile;
    }

    private String getDefaultResourceName(final File file) {
        return file.getAbsolutePath().substring(mWorkDir.getAbsolutePath().length() + 1);
    }

    @Override
    public void dispose() {
        FileUtils.deleteRecursive(mWorkDir);
        mLocaleFiles.clear();
        iconFile = null;
    }
}