Skip to content

Commit

Permalink
#14 #88 Add Discriminator class.
Browse files Browse the repository at this point in the history
  • Loading branch information
azurepolarbear committed Jun 1, 2024
1 parent 620152a commit 6f8555f
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/main/discriminator/discriminator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2024 brittni and the polar bear LLC.
*
* This file is a part of brittni and the polar bear's Generative Art Library,
* which is released under the GNU Affero General Public License, Version 3.0.
* You may not use this file except in compliance with the license.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. See LICENSE or go to
* https://www.gnu.org/licenses/agpl-3.0.en.html for full license details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*/

import {PaletteColor} from 'palette';

import {Discriminators} from './discriminators';

/**
* Methods for evaluating if objects implement various interfaces.
*
* @category Discriminator
*/
export class Discriminator {
/**
* Determines if the given object is a {@link PaletteColor}
* (i.e. implements the PaletteColor interface).
*
* @param object
*
* @returns `true` if the given object implements
* the {@link PaletteColor} interface, `false` if it does not.
*/
public static isPaletteColor(object: any): object is PaletteColor {
let hasMatch: boolean = false;

if (object) {
hasMatch = object.DISCRIMINATOR === Discriminators.PALETTE_COLOR;
}

return hasMatch;
}
}

0 comments on commit 6f8555f

Please sign in to comment.