1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.dynamicmime.testapp.util; 18 19 import android.dynamicmime.testapp.assertions.MimeGroupAssertions; 20 import android.dynamicmime.testapp.commands.MimeGroupCommands; 21 22 import androidx.annotation.Nullable; 23 24 import java.util.Set; 25 26 /** 27 * Base class for commands/queries related to MIME groups 28 * Allows independent implementations for commands and assertions 29 */ 30 public class MimeGroupOperations extends MimeGroupAssertions implements MimeGroupCommands { 31 private MimeGroupCommands mCommands; 32 private MimeGroupAssertions mAssertions; 33 MimeGroupOperations(MimeGroupCommands commands, MimeGroupAssertions assertions)34 public MimeGroupOperations(MimeGroupCommands commands, MimeGroupAssertions assertions) { 35 mCommands = commands; 36 mAssertions = assertions; 37 } 38 39 @Override assertMatchedByMimeGroup(String mimeGroup, String mimeType)40 public final void assertMatchedByMimeGroup(String mimeGroup, String mimeType) { 41 mAssertions.assertMatchedByMimeGroup(mimeGroup, mimeType); 42 } 43 44 @Override assertNotMatchedByMimeGroup(String mimeGroup, String mimeType)45 public final void assertNotMatchedByMimeGroup(String mimeGroup, String mimeType) { 46 mAssertions.assertNotMatchedByMimeGroup(mimeGroup, mimeType); 47 } 48 49 @Override assertMimeGroupInternal(String mimeGroup, Set<String> mimeTypes)50 public final void assertMimeGroupInternal(String mimeGroup, Set<String> mimeTypes) { 51 mAssertions.assertMimeGroupInternal(mimeGroup, mimeTypes); 52 } 53 54 @Override setMimeGroup(String mimeGroup, Set<String> mimeTypes)55 public void setMimeGroup(String mimeGroup, Set<String> mimeTypes) { 56 mCommands.setMimeGroup(mimeGroup, mimeTypes); 57 } 58 59 @Nullable 60 @Override getMimeGroupInternal(String mimeGroup)61 public Set<String> getMimeGroupInternal(String mimeGroup) { 62 return mCommands.getMimeGroupInternal(mimeGroup); 63 } 64 getCommands()65 public MimeGroupCommands getCommands() { 66 return mCommands; 67 } 68 getAssertions()69 public MimeGroupAssertions getAssertions() { 70 return mAssertions; 71 } 72 setCommands(MimeGroupCommands commands)73 public void setCommands(MimeGroupCommands commands) { 74 mCommands = commands; 75 } 76 setAssertions(MimeGroupAssertions assertions)77 public void setAssertions(MimeGroupAssertions assertions) { 78 mAssertions = assertions; 79 } 80 } 81