--- /dev/null
+/*
+ * Copyright (c) 2018. Developed by Hedgecode.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hedgecode.chess.domain;
+
+/**
+ * Common Adapter Interface.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public interface Adapter<TargetType> {
+
+ Class<TargetType> getTargetClass();
+
+}
*
* @author Dmitry Samoshin aka gotty
*/
-public interface AuthorAdapter<TargetType> {
+public interface AuthorAdapter<TargetType> extends Adapter<TargetType> {
void setId(TargetType target, Long id);
void setName(TargetType target, String name);
void setBiography(TargetType target, String biography);
void setComment(TargetType target, String comment);
- class Empty<TargetType> implements AuthorAdapter<TargetType> {
+ abstract class Empty<TargetType> implements AuthorAdapter<TargetType> {
@Override
public void setId(TargetType target, Long id) {
*
* @author Dmitry Samoshin aka gotty
*/
-public interface EtudeAdapter<TargetType> {
+public interface EtudeAdapter<TargetType> extends Adapter<TargetType> {
void setId(TargetType target, Long id);
void setHash(TargetType target, BigInteger hash);
void setDate(TargetType target, Date date);
void setDescription(TargetType target, String description);
- class Empty<TargetType> implements EtudeAdapter<TargetType> {
+ abstract class Empty<TargetType> implements EtudeAdapter<TargetType> {
@Override
public void setId(TargetType target, Long id) {
--- /dev/null
+/*
+ * Copyright (c) 2018. Developed by Hedgecode.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hedgecode.chess.domain;
+
+/**
+ *
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public class EtudePGNAdapter extends EtudeAdapter.Empty<Etude> {
+
+ @Override
+ public Class<Etude> getTargetClass() {
+ return Etude.class;
+ }
+
+ @Override
+ public void setPgn(Etude target, String pgn) {
+ // todo: assignFromPGN
+ }
+
+}
*
* @author Dmitry Samoshin aka gotty
*/
-public interface EtudeTypeAdapter<TargetType> {
+public interface EtudeTypeAdapter<TargetType> extends Adapter<TargetType> {
void setId(TargetType target, Long id);
void setBrief(TargetType target, String brief);
void setName(TargetType target, String name);
void setDescription(TargetType target, String description);
- class Empty<TargetType> implements EtudeTypeAdapter<TargetType> {
+ abstract class Empty<TargetType> implements EtudeTypeAdapter<TargetType> {
@Override
public void setId(TargetType target, Long id) {
public class AuthorDTOAdapter implements AuthorAdapter<AuthorDTO> {
@Override
+ public Class<AuthorDTO> getTargetClass() {
+ return AuthorDTO.class;
+ }
+
+ @Override
public void setId(AuthorDTO target, Long id) {
target.setId(id);
}
public class EtudeDTOAdapter implements EtudeAdapter<EtudeDTO> {
@Override
+ public Class<EtudeDTO> getTargetClass() {
+ return EtudeDTO.class;
+ }
+
+ @Override
public void setId(EtudeDTO target, Long id) {
target.setId(id);
}
public class EtudeTypeDTOAdapter implements EtudeTypeAdapter<EtudeTypeDTO> {
@Override
+ public Class<EtudeTypeDTO> getTargetClass() {
+ return EtudeTypeDTO.class;
+ }
+
+ @Override
public void setId(EtudeTypeDTO target, Long id) {
target.setId(id);
}