001/*
002 * Copyright 2019 Leibniz-Institut für Analytische Wissenschaften – ISAS – e.V..
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package de.isas.mztab2.io.validators;
017
018import de.isas.mztab2.model.Metadata;
019import java.util.Arrays;
020import java.util.Collections;
021import java.util.List;
022import uk.ac.ebi.pride.jmztab2.utils.errors.LogicalErrorType;
023import uk.ac.ebi.pride.jmztab2.utils.errors.MZTabError;
024import uk.ac.ebi.pride.jmztab2.utils.parser.MZTabParserContext;
025
026/**
027 * Validates that smallMoleculeQuantificationUnit is neither null nor empty.
028 *
029 * @author nilshoffmann
030 */
031public class SmallMoleculeQuantificationUnitValidator implements MetadataValidator<Metadata> {
032
033    @Override
034    public List<MZTabError> validateRefine(Metadata metadata, MZTabParserContext parserContext) {
035        if (metadata.getSmallMoleculeQuantificationUnit() == null) {
036            return Arrays.asList(new MZTabError(
037                    LogicalErrorType.NotDefineInMetadata, -1,
038                    Metadata.Properties.smallMoleculeQuantificationUnit + ""));
039        }
040        return Collections.emptyList();
041    }
042
043}