001/*
002 * Copyright (c) 2015-2020, Oracle and/or its affiliates. All rights reserved.
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 implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.tribuo.provenance.impl;
018
019import com.oracle.labs.mlrg.olcut.provenance.Provenance;
020import com.oracle.labs.mlrg.olcut.provenance.primitives.StringProvenance;
021import com.oracle.labs.mlrg.olcut.util.Pair;
022import org.tribuo.DataSource;
023import org.tribuo.provenance.DataSourceProvenance;
024
025import java.util.Collections;
026import java.util.Iterator;
027import java.util.Map;
028
029/**
030 * An empty DataSourceProvenance, should not be used except by the provenance removal system.
031 */
032public final class EmptyDataSourceProvenance implements DataSourceProvenance {
033    private static final long serialVersionUID = 1L;
034
035    EmptyDataSourceProvenance() { }
036
037    public EmptyDataSourceProvenance(Map<String,Provenance> map) {}
038
039    @Override
040    public String getClassName() {
041        return DataSource.class.getName();
042    }
043
044    @Override
045    public Iterator<Pair<String, Provenance>> iterator() {
046        return Collections.singletonList(new Pair<>(CLASS_NAME,(Provenance)new StringProvenance(CLASS_NAME,getClassName()))).iterator();
047    }
048
049    @Override
050    public boolean equals(Object other) {
051        return other instanceof EmptyDataSourceProvenance;
052    }
053
054    @Override
055    public int hashCode() {
056        return 31;
057    }
058
059    @Override
060    public String toString() {
061        return generateString("EmptyDataSource");
062    }
063}