1 package org.apache.maven.shared.io.scan.mapping;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.maven.shared.io.scan.InclusionScanException;
23
24 import java.util.Set;
25 import java.util.Collections;
26 import java.io.File;
27
28 /**
29 * Maps a set of input files to a single output file.
30 *
31 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
32 * @version $Id: SingleTargetMapping.java 1719477 2015-12-11 17:33:58Z khmarbaise $
33 */
34 public class SingleTargetMapping
35 implements SourceMapping
36 {
37 private String sourceSuffix;
38
39 private String outputFile;
40
41 /**
42 * @param sourceSuffix source suffix.
43 * @param outputFile output file.
44 */
45 public SingleTargetMapping( String sourceSuffix, String outputFile )
46 {
47 this.sourceSuffix = sourceSuffix;
48
49 this.outputFile = outputFile;
50 }
51
52 /** {@inheritDoc} */
53 public Set<File> getTargetFiles( File targetDir, String source )
54 throws InclusionScanException
55 {
56 if ( !source.endsWith( sourceSuffix ) )
57 {
58 return Collections.<File>emptySet();
59 }
60
61 return Collections.singleton( new File( targetDir, outputFile ) );
62 }
63 }