uk.ac.stfc.isis.ibex.configserver.json.PVsConverter.java Source code

Java tutorial

Introduction

Here is the source code for uk.ac.stfc.isis.ibex.configserver.json.PVsConverter.java

Source

/*
* This file is part of the ISIS IBEX application.
* Copyright (C) 2012-2015 Science & Technology Facilities Council.
* All rights reserved.
*
* This program is distributed in the hope that it will be useful.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution.
* EXCEPT AS EXPRESSLY SET FORTH IN THE ECLIPSE PUBLIC LICENSE V1.0, THE PROGRAM 
* AND ACCOMPANYING MATERIALS ARE PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES 
* OR CONDITIONS OF ANY KIND.  See the Eclipse Public License v1.0 for more details.
*
* You should have received a copy of the Eclipse Public License v1.0
* along with this program; if not, you can obtain a copy from
* https://www.eclipse.org/org/documents/epl-v10.php or 
* http://opensource.org/licenses/eclipse-1.0.php
*/

package uk.ac.stfc.isis.ibex.configserver.json;

import java.util.Arrays;
import java.util.Collection;

import uk.ac.stfc.isis.ibex.configserver.configuration.PV;
import uk.ac.stfc.isis.ibex.epics.conversion.ConversionException;
import uk.ac.stfc.isis.ibex.epics.conversion.Converter;

import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;

@SuppressWarnings("checkstyle:magicnumber")
public class PVsConverter extends Converter<String[][], Collection<PV>> {

    @Override
    public Collection<PV> convert(String[][] value) throws ConversionException {
        return Lists.newArrayList(Iterables.transform(Arrays.asList(value), new Function<String[], PV>() {
            @Override
            public PV apply(String[] info) {
                return new PV(info[0], info[1], info[2], info[3]);
            }
        }));
    }
}